Skip to content

Instantly share code, notes, and snippets.

@nimish-mehta
Last active March 25, 2020 13:56
Show Gist options
  • Save nimish-mehta/065cca534ace3eb55ed9f50e78963f74 to your computer and use it in GitHub Desktop.
Save nimish-mehta/065cca534ace3eb55ed9f50e78963f74 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