如何更改 Maven 日志记录级别以仅显示警告和错误? [英] How to change maven logging level to display only warning and errors?
问题描述
我想阻止 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.
- -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
plexus 加载器加载 simplelogger.properties
.
The plexus loader loads the simplelogger.properties
.
这篇关于如何更改 Maven 日志记录级别以仅显示警告和错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!