Skip to content

Instantly share code, notes, and snippets.

@manuelgeek
Forked from nimish-mehta/config.exs
Created March 25, 2020 13:56
Show Gist options
  • Save manuelgeek/dcfe497ae1361e8614e16e378ebf9b18 to your computer and use it in GitHub Desktop.
Save manuelgeek/dcfe497ae1361e8614e16e378ebf9b18 to your computer and use it in GitHub Desktop.
Configure Logging to File in Phoenix
# Configures Elixir's Logger to log to file
# ensure https://github.com/onkel-dirtus/logger_file_backend
# is installed in deps of the project in mix.exs
# reuses the original phoenix logging format.
config :logger, backends: [{LoggerFileBackend, :request_log}],
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
# Keep a seperate log file for each env.
# logs are stored in the root directory of the application
# inside the logs folder.
# Note: Remember to specify the format along with the metadata required.
# Configurable per LoggerFileBackend.
config :logger, :request_log,
path: "logs/request.#{Mix.env}.log",
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment