Maven cxf plugin logging
Asked Answered
D

3

13

I'm using the Apache cxf maven plugin (v3.3.0) to successfully to generate java wrappers.

However, the output from the maven build contains thousands of DEBUG logging lines from the wsdl2java which I am unable to remove. Is there an extraarg or other way to silence the process so I get just a success (or possibly failure) message?

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
                <defaultOptions>
                    <autoNameResolution>true</autoNameResolution>
                </defaultOptions>
                <wsdlOptions>
                    <!--Some Web Service -->
                    <wsdlOption>
                        <wsdl>https://some/web/service.wsdl</wsdl>
                        <extraargs>
                            <extraarg>-client</extraarg>
                            <extraarg>-quiet</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>com.foo.bar</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Derby answered 25/4, 2019 at 15:4 Comment(0)
R
5

Sorry for not getting into the root solutions, but adding this in my dependencies help:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j2</artifactId>
    <scope>provided</scope>
</dependency>

or put following in plugin execution helps too except for velocity logs

<additionalJvmArgs>
    -Dorg.apache.cxf.Logger=null
</additionalJvmArgs>

Hope this would give a hints for someone to come out with a much proper solution.

Residuum answered 28/3, 2020 at 10:19 Comment(0)
F
11

It appears that under Java 9+ the plugin forces code generation in a forked JVM regardless of the default being documented as false and regardless of any explicit configuration of this option. The plugin execution doesn't see any logging configuration from the project. CXF is logging using java.util.logging and any log down to FINER severity gets printed to the console.

I solved this by providing an explicit path to a logging configuration file to the forked JVM using the plugin's additionalJvmArgs configuration option:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf-plugin.version}</version>
    <configuration>
        <additionalJvmArgs>-Dlogback.configurationFile=${project.basedir}/src/test/resources/logback-codegen.xml</additionalJvmArgs>
    </configuration>
</plugin>

The system property for Logback (as in my case) is logback.configurationFile. For Log4j that would be log4j.configurationFile.

In the logging configuration file the following loggers can be added (Logback):

<!-- entries below silence excessive logging from cxf-codegen-plugin -->
<logger name="org.apache.cxf" level="info"/>
<logger name="org.apache.velocity" level="info"/>

This way the plugin execution will still print to the console all warnings and errors, but all the repetitive debug information goes away. The drawback is that you need to have such a logging configuration file visible in each of your projects. But then, you probably should have one anyway. The same one as for (unit) tests can often be used.

Forensic answered 10/6, 2020 at 22:19 Comment(0)
R
5

Sorry for not getting into the root solutions, but adding this in my dependencies help:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j2</artifactId>
    <scope>provided</scope>
</dependency>

or put following in plugin execution helps too except for velocity logs

<additionalJvmArgs>
    -Dorg.apache.cxf.Logger=null
</additionalJvmArgs>

Hope this would give a hints for someone to come out with a much proper solution.

Residuum answered 28/3, 2020 at 10:19 Comment(0)
G
1

Using maven-3.8.4 and cxf-codegen-plugin:3.5.1:wsdl2java, I've reduced log level with:

<configuration>
  <additionalJvmArgs>-D.level=WARN</additionalJvmArgs>
</configuration>

More details here: Apache CXF

Gybe answered 30/11, 2022 at 16:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.