通过maven获取构建日志文件

发布于 2024-09-13 08:19:28 字数 860 浏览 1 评论 0原文

是否可以在不使用管道运算符的情况下获取 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)

我知道可以从 Maven 更改输出级别,但不知道可以将其保存在日志文件中。每次尝试通过 log4j.properties 文件来完成这项工作对我来说都不起作用。我已经将它们放入 src/main/resources 中的 Corporate-pom-project 以及 child-pom-projects 中。将文件包含到类路径和 maven 目录中似乎也不起作用。 无论如何,是否可以通过 log4j 配置将 Maven 输出获取到具有指定调试级别的日志文件,最适合。我认为这是可能的,但我尝试过的似乎都不起作用。 有人对我这个问题有提示或答案吗?

提前致谢, 汤米男孩66

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗫嚅 2024-09-20 08:19:28

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

mvn goal > build.log

但在 Maven 3.x 中可以(MNG-4157MNG-第3183章

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

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文