通过maven获取构建日志文件[英] Getting a build logfile by maven

本文是小编为大家收集整理的关于通过maven获取构建日志文件的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

是否可以通过不使用管道操作器来获取Maven-build过程的日志文件?我的意思是通常会出现在类似的控制台窗口中的输出:

[INFO] ------------------------------------------------------------------------
[INFO] Building base_project 01.00.000
[INFO] ------------------------------------------------------------------------
[WARNING] While downloading sun-javamail:mail:1.3.1
  This artifact has been relocated to javax.mail:mail:1.3.1.
  http://maven.apache.org/guides/mini/guide-coping-with-sun-jars.html
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (CLEAN TARGET FOLDER)

我知道从M​​aven更改输出级别的可能性,但没有一个选择将其放入日志文件中的可能性.每次尝试通过log4j.properties文件对我不起作用.我已经将它们放在SRC/Main/Main/Resources中的Corporate-Pom项目中,也将它们放在儿童项目中.将文件包含在classpath和maven-directory中似乎也不起作用. 无论如何,是否可以将Mavens输出输出到具有指定的Debuglevel的日志文件,最适合log4j-configuration.我认为这是可能的,但是我尝试过的任何事情似乎都没有起作用. 是否有人对我有提示或答案?

预先感谢 Tommyboy66

推荐答案

Maven 2.x中不支持,您必须将输出管输送到文件中:

mvn goal > build.log

但在Maven 3.x( mng-4157 罢工>,<罢工> mng-3183

 -l,--log-file <arg>                    Log file to where all build output
                                        will go.

本文地址:https://www.itbaoku.cn/post/1574920.html

问题描述

is it possible to get a logfile of the maven-build process with not using a pipe-operator? I mean the output that normally comes in console window like that:

[INFO] ------------------------------------------------------------------------
[INFO] Building base_project 01.00.000
[INFO] ------------------------------------------------------------------------
[WARNING] While downloading sun-javamail:mail:1.3.1
  This artifact has been relocated to javax.mail:mail:1.3.1.
  http://maven.apache.org/guides/mini/guide-coping-with-sun-jars.html
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (CLEAN TARGET FOLDER)

I know about the possibility to change the output-level from maven, but not an option to get this in a logfile. Every try to get this work by a log4j.properties file does not work for me. I already put them in corporate-pom-project in src/main/resources and also in child-pom-projects. Including the file to classpath and in maven-directory seems not to work,too. Anyway, is it possible to get mavens output to a logfile with specified debuglevel, most suitable by log4j-configuration. I think this is possible, but nothing I tried seems to work. Is there anybody has a hint or an answer to this question for me?

Thanks in advance, tommyboy66

推荐答案

Not supported in Maven 2.x, you have to pipe the output into a file:

mvn goal > build.log

But possible in Maven 3.x (MNG-4157, MNG-3183):

 -l,--log-file <arg>                    Log file to where all build output
                                        will go.