erlang-lager / lager

A logging framework for Erlang/OTP
Apache License 2.0
1.12k stars 455 forks source link

lager.app env overwrites default handlers #215

Closed fogfish closed 7 years ago

fogfish commented 10 years ago

application:start(lager) applies all lager setting to application env, including default handlers {handlers, [ {lager_console_backend, info}, {lager_file_backend, [ {file, "log/error.log"}, {level, error}, {size, 10485760}, {date, "$D0"}, {count, 5}]}, {lager_file_backend, [ {file, "log/console.log"}, {level, info}, {size, 10485760}, {date, "$D0"}, {count, 5}]} ]},

Unfortunately, it also overwrites handlers configured by the application. The proposal is remove handlers from lager.app. The default handlers are installed anyway from lager_app.erl

Vagabond commented 10 years ago

Are you talking about handlers defined in like an app.config?

fogfish commented 10 years ago

I am talking about handlers defined at lager.app / lager.app.src

Here is code snippet: application:set_env(lager, handlers, [{lager_console_backend, [notice, {lager_default_formatter, [time, " [",severity,"] ", message, "\n"]}]}]). application:start(lager). application:get_env(lager, handlers).

Please note that get_env return different value then it was set due to env configuration at lager.app This issue is not visible if you bake an Erlang node and mange sys.config but issue is terrible when you start lager according to the snippet I sent to you.

Vagabond commented 10 years ago

Right, I see what you mean now. If you want to make a PR that updates the defaults in lager_app.erl and removes them from the .app file, I'll merge it. I don't have time to get to it right now otherwise.

fogfish commented 10 years ago

The call is on your side, the pull request is here b3f3f68

jadeallenx commented 7 years ago

Startup code changed considerably in 3.x. If this is still an issue, please reopen.