Conflict between lager and elixir logger when using amqp as a dependency
Closed this issue ยท 11 comments
When adding amqp ~> 1.0.0 as dependency in a fresh mix project and starting interactive mix, we get an error message:
09:58:35.987 [error] Supervisor 'Elixir.Logger.Supervisor' had child 'Elixir.Logger.ErrorHandler' started with 'Elixir.Logger.Watcher':start_link({error_logger,'Elixir.Logger.ErrorHandler',{true,false,500}}) at <0.455.0> exit with reason normal in context child_terminated
This can be mitigated by starting lager before logger in our application, but I think it is unfortunate to change all our applications code for fixing this error.
I noted it here. But, yes, if anyone knows better solution please share it with us here.
@ono @Fruetel What do you think of adding lager_logger (https://hex.pm/packages/lager_logger) as a new dependency?
An additional step of including the extra config to the main application's config.exs (https://github.com/PSPDFKit-labs/lager_logger/blob/master/config/config.exs) will still be required, I think (needs to be tested).
@pma Thanks for the quick response! The fix you suggest is certainly better than starting lager in our main applications. It is still a bit annoying, since we need to change this in a lot of applications, but I don't know a better solution either.
However there might not be much point to include it as amqp's dependency because you still have to configure larger. Maybe mentioning it in our README is the best we can do?
You are right. The main app needs to add stuff to the config.exs, otherwise lager_logger doesn't change the described behaviour.
Compared to what is already mentioned in the README the only benefit would be a single log output for both Elixir and Erlang.
@ono Mentioning the lager stuff in the READMe might be a good idea. It's the first place I'm looking into when I encounter any problems. I wasn't aware you mentioned the new dependencies in the wiki.
So how we are about this?
Sorry for the noobie question here... how can I work around this? I think I didn't get it... my fresh new HelloWorld example gave me this same error log.
Today this is how I'm starting my application:
def application do
[
# Starts the Supervisor with the HelloWorldConsumer Worker
mod: {HelloRabbit, []},
extra_applications: [:logger, :amqp]
]
end
Am I'm initializing it wrong?
Changing your extra_applications line to
extra_applications: [:lager, :logger, :amqp]
should be enough to get rid of the error message.
It worked! Thanks!
We should create a section in the README.md about it, right?
If this is the final solution and this approach doesn't contain any potencial problems, we could close this issue when the documentation section were written.
Added the information to README. Thanks guys!