问题描述
我正在尝试更改Maven默认使用的简单记录器,并将其更改为Log4j2.
I'm trying to change the simple logger that Maven uses by default and change it for Log4j2.
我尝试将新记录器的罐子添加到Maven lib
中,但是没有用.
I've tried adding the jars of the new logger to the Maven lib
but it did not work.
有人知道如何从简单的记录器迁移到最新版本的记录器吗?
Does any one know how to migrate from the simple logger to a newest version of the logger?
推荐答案
Maven使用SLF4J API记录消息.默认情况下,它使用slf4j-simple
实现.如果要更改此日志记录实现,则只需修改Maven安装,如下所示:
Maven uses SLF4J API to log messages. By default, it uses slf4j-simple
implementation. If you want to change this logging implementation, you just need to modify your Maven installation like this:
- 从Maven安装的
lib
目录中删除slf4j-simple
jar(您可能还希望将其重命名为.old
,以防日后回滚) - 将其替换为其他一种实现方式( Log4j 2 SLF4J绑定(针对您的情况)
- remove the
slf4j-simple
jar from thelib
directory of your Maven installation (you might also want to rename it to.old
, in case you want to roll it back in the future) - replace it with one of the alternative implementations (Log4j 2 SLF4J Binding in your case)
然后,记录器的配置与之前的完全相同(在此处记录).
The configuration of the logger is then exactly the same as before (documented here).
这篇关于如何更改默认的Maven记录器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!