如何更改Maven日志记录级别以仅显示警告和错误? [英] How to change maven logging level to display only warning and errors?

查看:877
本文介绍了如何更改Maven日志记录级别以仅显示警告和错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想防止Maven显示INFO消息,我只希望看到警告和错误(如果有).

I want to prevent maven from displaying INFO messages, I want to see only WARNINGS and ERRORS (if any).

如何才能做到这一点,最好通过更改调用maven的命令行来实现?

How can I achieve this, preferably by changing the command line that calls maven?

推荐答案

回答您的问题

我进行了一次小调查,因为我也对该解决方案感兴趣.

Answering your question

I made a small investigation because I am also interested in the solution.

根据 http://books.sonatype .com/mvnref-book/reference/running-sect-options.html#running-sect-verbose-option

  • -e错误
  • -X用于调试
  • -q仅表示错误

当前,maven 3.1.x使用SLF4J登录到System.out. 您可以在以下文件中修改日志记录设置:

Currently maven 3.1.x uses SLF4J to log to the System.out . You can modify the logging settings at the file:

${MAVEN_HOME}/conf/logging/simplelogger.properties

根据页面: http://maven.apache.org/maven-logging.html

我认为您应该能够通过命令行参数来设置简单记录器的默认日志级别,如下所示:

I think you should be able to setup the default Log level of the simple logger via a command line parameter, like this:

$ mvn clean package -Dorg.slf4j.simpleLogger.defaultLogLevel=debug

但是我无法正常运行.我猜唯一的问题是,maven从类路径的配置文件中获取了默认级别.我还通过System.properties尝试了一些其他设置,但所有设置均未成功.

But I could not get it to work. I guess the only problem with this is, maven picks up the default level from the config file on the classpath. I also tried a couple of other settings via System.properties, but all of them were unsuccessful.

您可以在github上找到slf4j的来源: slf4j github

You can find the source of slf4j on github here : slf4j github

此处的Simplelogger的来源:slf4j/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java

The source of the simplelogger here : slf4j/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java

丛集加载器加载simplelogger.properties.

这篇关于如何更改Maven日志记录级别以仅显示警告和错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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