Sentry.LoggerBackend (sentry v8.0.6) View Source

Report Logger events like crashed processes to Sentry. To include in your application, start this backend in your application start/2 callback:

# lib/my_app/application.ex
def start(_type, _args) do
  Logger.add_backend(Sentry.LoggerBackend)

Sentry context will be included in metadata in reported events. Example:

Sentry.Context.set_user_context(%{
  user_id: current_user.id
})

Configuration

  • :excluded_domains - Any messages with a domain in the configured list will not be sent. Defaults to [:cowboy] to avoid double reporting events from Sentry.PlugCapture.

  • :metadata - To include non-Sentry Logger metadata in reports, the :metadata key can be set to a list of keys. Metadata under those keys will be added in the :extra context under the :logger_metadata key. Defaults to [].

  • :level - The minimum Logger level to send events for. Defaults to :error.

  • :capture_log_messages - When true, this module will send all Logger messages. Defaults to false, which will only send messages with metadata that has the shape of an exception and stacktrace.

Example:

config :logger, Sentry.LoggerBackend,
  # Also send warn messages
  level: :warn,
  # Send messages from Plug/Cowboy
  excluded_domains: [],
  # Include metadata added with `Logger.metadata([foo_bar: "value"])`
  metadata: [:foo_bar],
  # Send messages like `Logger.error("error")` to Sentry
  capture_log_messages: true

Link to this section Summary

Functions

Callback implementation for :gen_event.handle_call/2.

Callback implementation for :gen_event.handle_info/2.

Callback implementation for :gen_event.init/1.

Callback implementation for :gen_event.terminate/2.

Link to this section Functions

Link to this function

code_change(old_vsn, state, extra)

View Source

Callback implementation for :gen_event.code_change/3.

Callback implementation for :gen_event.handle_call/2.

Link to this function

handle_event(arg1, state)

View Source

Callback implementation for :gen_event.handle_event/2.

Callback implementation for :gen_event.handle_info/2.

Callback implementation for :gen_event.init/1.

Link to this function

terminate(reason, state)

View Source

Callback implementation for :gen_event.terminate/2.