The Logger backend for Sentry.
The package can be installed as:
- Add
logger_sentry
to yourmix.exs
file
def deps do
[{:logger_sentry, "~> 0.1.0"}]
end
- Configure your config file, just like:
config :logger,
backends: [:console, Logger.Backends.Sentry],
sentry: [level: :error,
metadata: [:application, :module, :function, :file, :line, :pid] # :all
]
If you want keep console
backend in Logger event server, you should set backends
with [:console, Logger.Backends.Sentry]
. And sentry backend just support three options:
- level
- metadata
just like as console
backend.
Just like using Logger.
Logger.debug("this is one debug message")
Logger.info("this is one info message")
Logger.warn("this is one warning message")
Logger.error("this is one error message, if you set sentry logger level with `error`, the message will sent to your sentry server")
Logger.Backends.Sentry.level
Logger.Backends.Sentry.level(:error)
Logger.Backends.Sentry.metadata
Logger.Backends.Sentry.metadata([])
Logger.Backends.Sentry.metadata(:all)
Logger.Backends.Sentry.metadata([:application, :module, :pid])
For use fingerprints in sentry dashboard easily, logger_sentry
support option to define generate fingerprints modules.
Now only support match error message and code location, and you can also self-define module to generate the fingerprints, just need define fingerprints/2
function in your self-define module.
And you need set the option for logger_sentry
application, just like:
config :logger_sentry,
fingerprints_mods: [
LoggerSentry.Fingerprint.MatchMessage, # [code source](./lib/logger_sentry/fingerprint/match_message.ex)
LoggerSentry.Fingerprint.CodeLocation, # [code source](./lib/logger_sentry/fingerprint/code_location.ex)
Self.Define.Module
]