我在OTP 22中有一个Erlang项目,它使用内置的logger模块进行日志记录(在OTP 21中添加)。
我的项目使用依赖项“amqp_client”(https://github.com/rabbitmq/rabbitmq-erlang-client)。
这个依赖项使用lager库进行日志记录,所以lager也是我项目中的依赖项之一。
从我将lager添加到我的项目的那一刻起,通过logger完成的日志就不再工作了(我猜这是因为lager覆盖了logger也使用的VM的一些日志处理程序,或者类似的事情?)
有人有主意吗?
2条答案
按热度按时间1qczuiv01#
(This should be a comment to the answer provided by evnu, but I don't have the rep required for comment yet)
In lager you can see how it removes the default logger handler. You have 2 options if you leave
error_logger_redirect
on:Untested sys.config example for 2:
pkwftd7m2#
EDIT: I misread the question, it is about Erlang, not Elixir.
See the troubleshooting section of amqp :
Lager conflicts with Elixir logger
Lager is used by rabbit_common and it is not Elixir's best friend yet. You need a workaround.
In mix.exs, you have to load
:lager
before:logger
.Here is a sample configuration to silent rabbit_common logging.
Check out Lager and RabbitMQ documentation for more information.