Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a build logfile by maven

Tags:

maven-2

log4j

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

like image 347
danny Avatar asked Aug 09 '10 14:08

danny


People also ask

Where is the log file in Maven project?

Currently, Maven is using the SLF4J API for logging combined with the SLF4J Simple implementation. Therefore, to configure logging with SLF4J Simple, we can edit the properties in the ${maven. home}/conf/logging/simplelogger. properties file.

What does Maven use for logging?

Maven uses Plexus logging API with basic Maven implementation writing to stdout.

Does Maven use log4j?

java - A Maven plugin uses a library which logs with log4j - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.


1 Answers

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.
like image 137
Pascal Thivent Avatar answered Nov 16 '22 01:11

Pascal Thivent