View Source Sentry.LoggerBackend (Sentry v10.2.0)
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
})
:logger
handlerIn new projects, try to use
Sentry.LoggerHandler
rather than thisLogger
backend. Elixir will likely deprecateLogger
backends in the future in favor of:logger
handlers, which would lead to us eventually removing this backend.
configuration
Configuration
:excluded_domains
- Any messages with a domain in the configured list will not be sent. Defaults to[:cowboy]
to avoid double reporting events fromSentry.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[]
. If set to:all
, all metadata will be included.:all
is available since v9.0.0 of this library.:level
- The minimum [Logger level](https://hexdocs.pm/logger/Logger.html#module-levels to send events for. Defaults to:error
.:capture_log_messages
- Whentrue
, this module will send all Logger messages. Defaults tofalse
, which will only send messages with metadata that has the shape of an exception and stacktrace.
Example:
config :logger, Sentry.LoggerBackend,
# Also send warning messages
level: :warning,
# 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