languages / elixir / configuration / logging-to-multiple-devices

Elixir Configuration - Logging to Multiple Devices

The Elixir Logger includes support for logging to multiple backends. Logging to a file or :stdout in addition to Timber is simple:

Logging to :stdout as well as Timber

Logging to :stdout uses the provided :console backend. You can read more about configuring the :console backend here.

1
2
3
4
# config/config.exs

config :logger,
  backends: [Timber.LoggerBackends.HTTP, :console]

Logging to a file as well as Timber

First, you'll need to add logger_file_backend as a dependency in your mix.exs file. Then configure your logger like so:

1
2
3
4
5
6
7
# config/config.exs

config :logger,
  backends: [Timber.LoggerBackends.HTTP, {LoggerFileBackend, :file_log}]

config :logger, :file_log,
  path: "/var/log/my_app/app.log"
Questions?

Chat with us, just click the talk button in the bottom right of this page.

Chat with us
Sign Up

Log better and solve problems faster, today. Install in under a minute.

Sign Up