1

I want to clean up/unify the log output of a Maven build. Unfortunately, a dependency of a maven plugin uses java.util.Logging (JUL). Simply adding org.slf4j:jul-to-slf4j as an additional dependency to redirect the log output doesn't help. Exclusions also don't work of course, because it's JUL and therefore not a dependency. Here's my configuration, containing the specific plugin and its dependency:

Configuration

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.7.11</version>
    <executions>...</executions>
    <configuration>
        <defaultOptions>
            <extraargs>
                <extraarg>-xjc-Xbg</extraarg>
            </extraargs>
        </defaultOptions>
    </configuration>
    <dependencies>
        <!-- This one uses JUL with logging level WARN -->
        <dependency>
            <groupId>org.apache.cxf.xjcplugins</groupId>
            <artifactId>cxf-xjc-boolean</artifactId>
            <version>2.7.0</version>
        </dependency>
    </dependencies>
</plugin>

Update

I've managed to turn off/configure JUL itself by adding a logging.properties file with the following content to the project's root folder:

# Turn off any java.util.Loggers (or use SEVERE to see problems)
.level=OFF

Additionally, I have to execute Maven with the following parameter (or set it into MAVEN_OPTS):

mvn clean install -Djava.util.logging.config.file=${basedir}/logging.properties

Remaining Question

Is there any way to achieve the same result without extra files and/or JVM parameters (pom.xml only)?

Markus Ratzer
  • 1,292
  • 3
  • 19
  • 29

3 Answers3

1

Following configuration for the plugin cxf-codegen-plugin prevented to show DEBUG log entries when building my project with maven:

<configuration>    
  <fork>once</fork>
  <additionalJvmArgs>
    -Dorg.apache.cxf.Logger=null
  </additionalJvmArgs>
</configuration>
Josema
  • 1,807
  • 1
  • 17
  • 15
1

Instead of a properties file or completely disabling all logging as suggested in another answer, you can also set the desired log level like this:

<additionalJvmArgs>-Dorg.apache.cxf.level=OFF</additionalJvmArgs>

The level needs to be one of the java.util.logging.Level.

kapex
  • 28,903
  • 6
  • 107
  • 121
0

I was having similar behavior: was getting WARNING messages from CXF 2.6.3 generated webservices classes when running my Struts2 test cases, polluting my test log.

Since the log trace wasn't showing from what package was sended, I was trying to config the wrong package.

I've added this to my setUp() test case method from my test that extends XWorkTestCase (or whatever you need):

public void setUp() throws Exception{
        super.setUp();      
        java.util.logging.Logger.getLogger("org.apache.cxf").setLevel(Level.OFF);       
    }

Then no more logging messages from CXF appears when I run my tests from maven.

exoddus
  • 2,230
  • 17
  • 27