How can I change the default Maven logger?

2019-08-07 16:53发布

I'm trying to change the simple logger that Maven uses by default and change it for Log4j2.

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?

1条回答
劳资没心,怎么记你
2楼-- · 2019-08-07 17:27

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:

  1. remove the slf4j-simple jar from the lib 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)
  2. 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).

查看更多
登录 后发表回答