As of sentry-elixir 7.0, Sentry now ship their own Sentry.LoggerBackend (including in 8.0 the ability to sent non-exception messages to Sentry), which should be used instead of this. As a result this project is now deprecated. Users are recommended to migrate to the new official Sentry.LoggerBackend as and when they upgrade their sentry-elixir version.
Provides a Logger
backend for Sentry, to automatically submit Logger events above a configurable threshold to Sentry
- Add
sentry_logger_backend
to your list of dependencies inmix.exs
:
def deps do
[{:sentry_logger_backend, "~> 0.1.0"}]
end
- Add SentryLoggerBackend to the list of logger backends in your config, e.g.
config :logger, backends: [:console, SentryLoggerBackend]
- Set the level threshold (defaults to :error - but see warning below):
config :logger, SentryLoggerBackend, level: :error
Can supply a custom fingerprint to a Logger call with the fingerprint
metadata, which should be a list(String.t)
(see Sentry's documentation for more info). For example:
Logger.warn "oh no - #{debugging data that's different each time}", fingerprint: ["oh-no"]
The current version of elixir-sentry logs problems encountered while posting to sentry at the :warn
level.
That means that if you configure the level threshold to anything other than :error
, and there's a problem posting to sentry, then this can result in an infinite loop of error-posting attempts.
The suggested solution for now, if you want to use a threshold other than :error
, is to use my fork of sentry-elixir, which adds :skip_sentry
metadata to that logger call. Future plans are to include a custom http client in sentry-logger-backend, see #1 .
This project is licensed under the MIT License.