Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the java.util.logging log level in maven (for Jenkins plugin (JenkinsRule) tests)

I'm writing a Jenkins plugin, and testing it using mvn verify and JenkinsRule. So far so good, but I'd like to be able to quieten the output; it's pages per test. What kind of config file do I use, and where do I put it?

I've tried a suitable log4j.properties (and just to be sure, a logging.properties) in src/test/resources (and thus target/test-classes); I've tried putting them in target/jenkins-for-test/WEB-INF/classes, that didn't help either.

In case it jogs anyone's memory, the output I'm trying to suppress are things like

Feb 08, 2014 2:26:40 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Feb 08, 2014 2:26:40 PM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins

and

Feb 08, 2014 2:26:44 PM hudson.PluginWrapper stop
INFO: Stopping javadoc
Feb 08, 2014 2:26:44 PM hudson.PluginWrapper stop
INFO: Stopping maven-plugin
like image 273
Paul Hicks Avatar asked Feb 08 '14 01:02

Paul Hicks


People also ask

How do I change the log level in Jenkins?

If you want to change the default/package log level temporally you have to go to Manage Jenkins > System Log > Log Levels and set the level that you want. The logger with no name is the default logger. All the loggers without a configured level inherit the level of the default logger.

What is Java Util logging level?

Description. java.util.logging. Provides the classes and interfaces of the JavaTM 2 platform's core logging facilities. javax.sql.rowset.spi. The standard classes and interfaces that a third party vendor has to use in its implementation of a synchronization provider.


1 Answers

Check this thread out : Logging level under maven surefire

There are a couple of things you can try. First, specify handlers in your logging.properties file by adding this line:

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

Second, you could add the logging.properties location to your pom.xml, like this:

<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>

Good luck!

like image 69
Mark Madej Avatar answered Oct 20 '22 23:10

Mark Madej