erlang-lager / lager

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

error message "logger:remove_handler(default) failed" printed at startup #507

Open notslang opened 5 years ago

notslang commented 5 years ago

I found a small issue where upgrading amqp_client from 3.7.13 to 3.7.14 causes an error message to be printed when I start up my Elixir application:

[error] calling logger:remove_handler(default) failed: :error {:badmatch, {:error, {:not_found, :default}}}

The error is being printed due to code introduced by this change, since lager is a dependency of amqp_client and was upgraded as a result of upgrading amqp_client. However, I have no idea if this is a defect in lager or if it's another dependency using lager incorrectly, and I'm not sure how to check.

I'm using Erlang/OTP 22, if that helps.

Is this the right place to report this?

hauleth commented 5 years ago

@notslang yes, this is due to fact that Elixir is also removing default handler if you have handle_otp_reports set to true (the default). So you have 2 options:

jadencodes commented 4 years ago

This is a bit late, but I ran into the same thing; there is another potential fix for this mentioned at the bottom of the amqp client page. You need to add :lager to start before :logger. So your file will look something like this:

def application do
    [
      extra_applications: [:lager, :logger, :amqp]
    ]
end

Hope this is useful.

linkdd commented 3 years ago

For what it's worth, none of the above worked for me.

I'm using Elixir 1.12 / OTP 24. And this dependency overwrites the logger configuration.

When running mix test on my project, there should be no logging, but here it's printing so much I cannot see my test results anymore.