A Logger backend that forwards log messages to lager.
LogLagerBackend is in early beta. If you try it and has an issue, report them.
First, add LogLagerBackend to your mix.exs dependencies:
def deps do
[{:log_lager_backend, "~> 0.0.3"}]
end
Then, update your dependencies:
$ mix deps.get
Setup a configuration in config/config.exs.
config :logger,
backends: [LogLagerBackend],
handle_otp_reports: false
config :logger, LogLagerBackend,
level: :info,
format: "$metadata - $message",
metadata: [:module]
The options level, format and metadata will be treated like by the
:console backend. If a message has the right level it will be formatted and
forwarded to lager. All options for lager have an impact on our forwarded
message.
The backend can also be configured at runtime.
Logger.add_backend(LogLagerBackend)
Logger.configure_backend(
LogLagerBackend,
format: "$message - $metadata",
metadata: [
:client_id,
],
level: :warn
)
# and if you don't want the :console backend
Logger.remove_backend(:console)