Maven 可以变得不那么冗长吗?
Maven 输出了太多符合我口味的输出行(我喜欢 Unix 方式:没有消息就是好消息)。
我想删除所有 [INFO]
行,但我找不到任何提及控制 Maven 详细程度的参数或配置设置。
有没有类似LOG4J的方法来设置日志级别?
Maven spews out far too many lines of output to my taste (I like the Unix way: no news is good news).
I want to get rid of all [INFO]
lines, but I couldn't find any mention of an argument or config settings that controls the verbosity of Maven.
Is there no LOG4J-like way to set the log level?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您可以尝试
-q
开关。You can try the
-q
switch.如上所述的
-q
就是您所需要的。 另一种选择可能是:并且还将输出消息或多或少地减少到必需品。
-q
as said above is what you need. An alternative could be:And will also reduce the output messages more or less to the essentials.
Maven 3.1.x 使用 SLF4j 进行日志记录,您可以在 https:// 找到如何配置它的说明。 maven.apache.org/maven-logging.html
简而言之:修改
${MAVEN_HOME}/conf/logging/simplelogger.properties
,或者通过设置相同的属性MAVEN_OPTS
环境变量。例如:将
MAVEN_OPTS
设置为-Dorg.slf4j.simpleLogger.log.org.apache.maven.cl i.transfer.Slf4jMave nTransferListener=wa rn
配置日志记录批处理模式传输监听器,-Dorg.slf4j.simpleLogger.defaultLogLevel=warn 设置默认日志级别。Maven 3.1.x uses SLF4j for logging, you can find instructions how to configure it at https://maven.apache.org/maven-logging.html
In short: Either modify
${MAVEN_HOME}/conf/logging/simplelogger.properties
, or set the same properties via theMAVEN_OPTS
environment variable.For example: setting
MAVEN_OPTS
to-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
configures the logging of the batch mode transfer listener, and-Dorg.slf4j.simpleLogger.defaultLogLevel=warn
sets the default log level.官方链接:
https://maven.apache.org/maven-logging.html
您可以添加JVM 参数:
注意大写。
Official link :
https://maven.apache.org/maven-logging.html
You can add in the JVM parameters :
Beware of UPPERCASE.
使用 -q 或 --quiet 命令行选项
Use the -q or --quiet command-line options
如果您只想摆脱
[INFO]
消息,您也可以这样做:要抑制所有输出(错误除外),您可以重定向
stdout
到/dev/null
:(这仅在您使用
bash
(或类似的 shell)运行 Maven 命令时有效。)If you only want to get rid of the
[INFO]
messages you also could do:To suppress all outputs (except errors) you could redirect
stdout
to/dev/null
with:(This only works if you use
bash
(or similar shells) to run the Maven commands.)现有答案可帮助您使用
--quiet
根据日志级别进行过滤。 我发现许多 INFO 消息对于调试很有用,但是下载工件日志消息(如下所示)噪音很大并且没有帮助。我找到了这个解决方案:
https ://blogs.itemis.com/en/in-a-nutshell-removing-artifact-messages-from-maven-log-output
The existing answer help you filter based on the log-level using
--quiet
. I found that many INFO messages are useful for debugging, however the downloading artifact log messages such as the following were noisy and not helpful.I found this solution:
https://blogs.itemis.com/en/in-a-nutshell-removing-artifact-messages-from-maven-log-output
Maven 3.6.1 (2019 年 4 月)< /a>,您现在有一个在交互模式下下载/上传时抑制传输进度的选项。
这就是 Ray 提出的在评论中使用 MNG-6605 和 PR 239。
With Maven 3.6.1 (April 2019), you now have an option to suppress the transfer progress when downloading/uploading in interactive mode.
That is what Ray proposed in the comments with MNG-6605 and PR 239.
我过去曾成功地通过使用此插件配置来静音单个警告,例如
com.example.X
:相对于 按照此处建议的方式在外部设置系统属性 是它会自动应用于所有构建/执行。
I've been successful in the past to mute individual warnings e.g. for
com.example.X
, by using this plugin configuration:The benefit over setting the system property externally as suggested here is that it automatically applies to all builds / executions.