I’m trying to use flatlog, in a mix project.
I have found that I need to add the following to config.exs
config :logger, handle_otp_reports: false
But I can’t work out how to modify usage instructions on flat log so they work in config.exs.
I’m trying to use flatlog, in a mix project.
I have found that I need to add the following to config.exs
config :logger, handle_otp_reports: false
But I can’t work out how to modify usage instructions on flat log so they work in config.exs.
You need to disable Elixir’s logger with the instruction given in the other post and then add your handler to Erlang logger, either directly via :logger.add_handler/3
or via :logger.add_handlers/1
and application configuration. So in the end your config will look like:
config :logger, handle_otp_reports: false
config :my_app, :logger, [
{:handler, :default, :logger_std_h,
%{formatter: {:flatlog, %{
map_depth: 3,
term_depth: 50
}}}
}
]
And in your Application.start/2
callback you need to do:
:logger.add_handlers(:my_app)
Is there not a way to generate the appropriate sys.config
so I don’t need to make the call in application.start?
Not in development. In production you can use:
config :kernel, :logger, [
{:handler, :default, :logger_std_h,
%{formatter: {:flatlog, %{
map_depth: 3,
term_depth: 50
}}}
}
]
And it should work as expected. Unfortunately Elixir do not reload kernel
configuration after it starts, so in development it is not possible to change configuration options for it.