문제

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?

도움이 되었습니까?

해결책

This still seems some closed issue in Maven, as you can see on:

https://issues.apache.org/jira/browse/MNG-519

The provided workaround looks not too bad, but you need to modify the maven installation.

다른 팁

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.

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; }'

Maven in Version 3.1 and 3.2 allow simpler configuration of the SLF4J based logger. You can specify "-l logfile" on the command line, and the default configuration of the SimpleLogger is in the config file conf/logging/simplelogger.properties.

If you want to turn on the default timestampts (milliseconds since start) you can simple change the property in this file: org.slf4j.simpleLogger.showDateTime=true.

As suggested by @eckes, default logging configuration file is available at /conf/logging/simplelogger.properties, from Maven 3.1.0 onward.

Change "org.slf4j.simpleLogger.showDateTime" property value to "true"

org.slf4j.simpleLogger.showDateTime=true

To change dateTimeFormat, as default is relative time in milliseconds.
Add below line in simplelogger.properties file.

org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS

References:
Maven logging: https://maven.apache.org/maven-logging.html
DateFormats: http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top