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

查看:238
本文介绍了通过Maven获取构建日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过不使用管道操作符来获取Maven构建过程的日志文件?我的意思是通常在控制台窗口中显示的输出是这样的:

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)

我知道可以从maven更改输出级别,但不是在日志文件中获取输出级别的选项.每次尝试通过log4j.properties文件获得此功能对我来说都不起作用.我已经将它们放在src/main/resources中的Corporate-pom-project中,也放在了child-pom-projects中.将文件包含到classpath和maven目录中似乎也不起作用. 无论如何,是否有可能将maven输出输出到具有指定调试级别的日志文件,最适合log4j-configuration.我认为这是可能的,但是我尝试过的任何方法似乎都没有效果. 有没有人对我有这个问题的提示或答案?

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?

预先感谢, tommyboy66

Thanks in advance, tommyboy66

推荐答案

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

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

mvn goal > build.log

但是在Maven 3.x中是可能的( MNG-4157 MNG-3183 ):

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

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

这篇关于通过Maven获取构建日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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