Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven log file configuration

How can I configure logging for maven build? The log which maven generates is not providing enought information like time stamp with each log statement. Where/what log config file maven uses?

like image 385
Sharad Yadav Avatar asked Nov 25 '10 09:11

Sharad Yadav


People also ask

Where is the Maven log file?

home}/conf/logging/simplelogger. properties file.

What is Maven configuration?

Maven configuration occurs at 3 levels: Project - most static configuration occurs in pom. xml. Installation - this is configuration added once for a Maven installation. User - this is configuration specific to a particular user.

What is mvnDebug?

MvnDebug. The Maven CLI comes prepackaged with an additional command that allows you to hook into executions with a debugger: mvnDebug . You can replace any mvn command with mvnDebug , and the command will immediately be queued up to execute once a debug listener hooks into it at the correct port.


2 Answers

You may be aware of this, and it will not print dates, but use mvn -X to print verbose output.

Additionally, you can always pipe the output of maven to some other utility (assuming your shell environment contains halfway competent tools). For instance mvn -X clean | awk '{print "("d")"$0}' "d=$(date)" prints out a date before each line in maven. I didn't bother formatting the date, but that's easily done with arguments to the date executable. Note that this won't really work for maven commands that require interactive user input, such as maven archetype:generate.

like image 59
whaley Avatar answered Oct 12 '22 23:10

whaley


Answer provided by @whaley is a good direction. However, the $(date) is evaluated only once at the beginning and then remains the same. I had to use an approach mentioned in Is there a Unix utility to prepend timestamps to stdin?:

mvn -X <goals> | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; }'
like image 42
Juraj Martinka Avatar answered Oct 12 '22 22:10

Juraj Martinka