Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging level under maven surefire

I'm unable to adjust java logging's logging level. I'm using maven surefire (mvn test), and trying to adjust from the default INFO to e.g. FINEST.

I have logging.properties file under src/test/resources/logging.properties

after compile, i see under target/test-classes, i see a logging.properties file with the intended config:

java.util.logging.ConsoleHandler.level=FINEST

javax.enterprise.system.container.ejb.level=FINE

...

however the console output from glassfish only have INFO / SEVERE level messages.

Where did I go wrong? or is this another pain in the butt thing with maven?

like image 731
Dzhu Avatar asked Oct 15 '10 02:10

Dzhu


People also ask

What is logging in Maven?

By default, Maven only logs the info, warning, and error logs. Also, for errors, it doesn't show the full stacktrace of that log. In order to see the full stacktrace, we can use the -e or –errors option: $ mvn -e clean compile // truncated cannot find symbol symbol: variable name location: class Compiled at org.

What is Maven failsafe plugin used for?

The Failsafe Plugin is used during the integration-test and verify phases of the build lifecycle to execute the integration tests of an application. The Failsafe Plugin will not fail the build during the integration-test phase, thus enabling the post-integration-test phase to execute.


2 Answers

I tried setting java.util.logging.config.file in the MAVEN_OPTS environment variable, which does not work but finally got it working by putting that system property in the pom.xml (and of course creating an appropriate logging.properties in src/test/resources):

    <plugins>       <plugin>         <artifactId>maven-surefire-plugin</artifactId>         <configuration>            <systemProperties>              <property>                 <name>java.util.logging.config.file</name>                <value>src/test/resources/logging.properties</value>              </property>            </systemProperties>         </configuration>       </plugin>     </plugins> 
like image 179
ehrencrona Avatar answered Oct 26 '22 15:10

ehrencrona


You need to specifiy your handlers in the logging file

handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler 

then it should work

like image 21
martin Avatar answered Oct 26 '22 13:10

martin