如何更改默认的Maven记录器? [英] How can I change the default Maven logger?

查看:69
本文介绍了如何更改默认的Maven记录器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改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:

  1. 从Maven安装的lib目录中删除slf4j-simple jar(您可能还希望将其重命名为.old,以防日后回滚)
  2. 将其替换为其他一种实现方式( Log4j 2 SLF4J绑定(针对您的情况)
  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).

这篇关于如何更改默认的Maven记录器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆