View Source Sentry.LoggerBackend (sentry v8.1.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
})
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[]
.:level
- The minimum Logger level 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
Link to this section Summary
Functions
Callback implementation for :gen_event.code_change/3
.
Callback implementation for :gen_event.handle_call/2
.
Callback implementation for :gen_event.handle_event/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
Callback implementation for :gen_event.code_change/3
.
Callback implementation for :gen_event.handle_call/2
.
Callback implementation for :gen_event.handle_event/2
.
Callback implementation for :gen_event.handle_info/2
.
Callback implementation for :gen_event.init/1
.
Callback implementation for :gen_event.terminate/2
.