Getting rid of Jakarta Commons Logging (used by Spring)
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 19 Dec 2015 15:10:22 +0000 (16:10 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 19 Dec 2015 15:15:20 +0000 (16:15 +0100)
README.md
cxf/web-services-spring-cxf-client/src/main/resources/log4j2.xml
cxf/web-services-spring-cxf-server/src/main/resources/log4j2.xml
cxf/web-services-spring-cxf/pom.xml
jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml
jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml
jaxb2/web-services-spring-jaxb2/pom.xml

index bd6a569..d29c636 100644 (file)
--- a/README.md
+++ b/README.md
@@ -11,6 +11,5 @@ mvn clean install -Dmaven.test.skip=true
 
 
 TODO: using Jetty instead of Tomcat
-TODO: logging Spring information
 
 For debugging: export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
index 18a4008..1bf2492 100644 (file)
@@ -1,13 +1,60 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="trace" strict="true"
+
+<!-- 
+       status: The level of internal Log4j events that should be logged to the console.
+       Valid values for this attribute are "trace", "debug", "info", "warn", "error" and "fatal".
+       
+       monitorInterval: The minimum amount of time, in seconds, that must elapse before the file configuration is checked for changes.
+       
+       
+       see https://logging.apache.org/log4j/2.x/manual/configuration.html
+ -->
+<Configuration status="error" strict="true" monitorInterval="30"
                 name="XMLConfigTest" packages="org.apache.logging.log4j.test">
+                
+       <!--
+               ALL > TRACE > DEBUG > INFO > WARN > ERROR > OFF
+               
+               ERROR by default.
+       -->
+                
     <Appenders>
         <Appender type="Console" name="STDOUT">
             <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
         </Appender>
     </Appenders>
     <Loggers>
-        <Root level="trace">
+    
+    
+        <!-- 
+               Specific log when request message from client or response message created by this client contains validation errors.
+               It is used by org.springframework.ws.client.support.interceptor.PayloadValidatingInterceptor
+         -->
+        <Logger name="org.springframework.ws.client.support.interceptor.AbstractValidatingInterceptor" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+
+        
+        <!-- 
+               Specific log level for Spring WS.
+        -->
+        <Logger name="org.springframework.ws" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+    
+               <!-- 
+               General logging Spring.
+        -->
+        <Logger name="org.springframework" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+
+               <!-- 
+                       Anything else will be using TRACE logging level.
+                -->        
+        <Root level="INFO">
             <AppenderRef ref="STDOUT"/>
         </Root>
     </Loggers>
index 18a4008..6ff67a4 100644 (file)
@@ -1,13 +1,73 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="trace" strict="true"
+
+<!-- 
+       status: The level of internal Log4j events that should be logged to the console.
+       Valid values for this attribute are "trace", "debug", "info", "warn", "error" and "fatal".
+       
+       monitorInterval: The minimum amount of time, in seconds, that must elapse before the file configuration is checked for changes.
+       
+       
+       see https://logging.apache.org/log4j/2.x/manual/configuration.html
+ -->
+<Configuration status="error" strict="true" monitorInterval="30"
                 name="XMLConfigTest" packages="org.apache.logging.log4j.test">
+                
+       <!--
+               ALL > TRACE > DEBUG > INFO > WARN > ERROR > OFF
+               
+               ERROR by default.
+       -->
+                
     <Appenders>
         <Appender type="Console" name="STDOUT">
             <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
         </Appender>
     </Appenders>
     <Loggers>
-        <Root level="trace">
+    
+    
+        <!-- 
+               Specific log when request message from client or response message created by this server contains validation errors.
+               It is used by org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor
+         -->
+        <Logger name="org.springframework.ws.soap.server.endpoint.interceptor.AbstractFaultCreatingValidatingInterceptor" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+        
+        
+        <!-- Specific log level for SOAP SoapEnvelopeLoggingInterceptor.
+                org.springframework.ws.soap.server.endpoint.SoapEnvelopeLoggingInterceptor
+                
+                see soap-ws.xml Spring configuration file.
+                
+                This configuration enables us to log the SOAP XML Request (received from client), Response (sent by this server) and Fault (sent by this server).
+       -->
+        <Logger name="org.springframework.ws.server.endpoint.AbstractLoggingInterceptor" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+        
+
+        
+        <!-- 
+               Specific log level for Spring WS.
+        -->
+        <Logger name="org.springframework.ws" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+    
+               <!-- 
+               General logging Spring.
+        -->
+        <Logger name="org.springframework" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+
+               <!-- 
+                       Anything else will be using TRACE logging level.
+                -->        
+        <Root level="INFO">
             <AppenderRef ref="STDOUT"/>
         </Root>
     </Loggers>
index a325a06..0e33534 100644 (file)
        </profiles>
 
        <dependencies>
+           <!--
+               1/3 Required dependency for log4j 2 with slf4j: binding between log4j 2 and slf4j
+       -->
                <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-slf4j-impl</artifactId>
                        <version>2.3</version>
                </dependency>
+               <!--
+               2/3 Required dependency for log4j 2 with slf4j: log4j 2 maven plugin (it is the log4j 2 implementation)
+       -->
                <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-core</artifactId>
                        <version>2.3</version>
                </dependency>
+               <!-- 
+                       3/3 Required dependency for getting rid of commons logging.
+                       This is the BRIDGE (no binding) between Jakarta Commons Logging (used by Spring) and whatever
+                       I am using for logging (in this case I am using log4j 2)
+                       See: http://www.slf4j.org/legacy.html
+                       
+                       We need exclusions in every dependency using Jakarta Commons Logging (see Spring dependencies below)
+                -->
+               <dependency>
+               <groupId>org.slf4j</groupId>
+               <artifactId>jcl-over-slf4j</artifactId>
+               <version>1.7.12</version>
+               </dependency>
                <dependency>
                        <groupId>cglib</groupId>
                        <artifactId>cglib</artifactId>
                                <groupId>org.springframework.ws</groupId>
                                <artifactId>spring-ws-core</artifactId>
                                <version>${spring.ws.version}</version>
+                               <!-- 
+                                       Required dependency for getting rid of commons logging and use my own logging library
+                                       (in my case I decided to use log4j 2 under slf4j)
+                                -->
+                               <exclusions>
+                               <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
                        </dependency>
                        <dependency>
                                <groupId>org.springframework.ws</groupId>
                                <artifactId>spring-xml</artifactId>
                                <version>${spring.ws.version}</version>
+                               <!-- 
+                                       Required dependency for getting rid of commons logging and use my own logging library
+                                       (in my case I decided to use log4j 2 under slf4j)
+                                -->
+                               <exclusions>
+                               <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
                        </dependency>
                        <dependency>
                                <groupId>org.jdom</groupId>
                                <artifactId>spring-ws-test</artifactId>
                                <version>${spring.ws.version}</version>
                                <scope>test</scope>
+                               <!-- 
+                                       Required dependency for getting rid of commons logging and use my own logging library
+                                       (in my case I decided to use log4j 2 under slf4j)
+                                -->
+                               <exclusions>
+                               <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>                           
                        </dependency>
                        <dependency>
                                <groupId>org.mockito</groupId>
                </dependencies>
        </dependencyManagement>
        <build>
+
                <pluginManagement>
                        <plugins>
                                <plugin>
                                </plugin>
                        </plugins>
                </pluginManagement>
+
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
index 18a4008..5bbca37 100644 (file)
@@ -1,14 +1,61 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="trace" strict="true"
+
+<!-- 
+       status: The level of internal Log4j events that should be logged to the console.
+       Valid values for this attribute are "trace", "debug", "info", "warn", "error" and "fatal".
+       
+       monitorInterval: The minimum amount of time, in seconds, that must elapse before the file configuration is checked for changes.
+       
+       
+       see https://logging.apache.org/log4j/2.x/manual/configuration.html
+ -->
+<Configuration status="error" strict="true" monitorInterval="30"
                 name="XMLConfigTest" packages="org.apache.logging.log4j.test">
+                
+       <!--
+               ALL > TRACE > DEBUG > INFO > WARN > ERROR > OFF
+               
+               ERROR by default.
+       -->
+                
     <Appenders>
         <Appender type="Console" name="STDOUT">
             <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
         </Appender>
     </Appenders>
     <Loggers>
-        <Root level="trace">
+    
+    
+        <!-- 
+               Specific log when request message from client or response message created by this client contains validation errors.
+               It is used by org.springframework.ws.client.support.interceptor.PayloadValidatingInterceptor
+         -->
+        <Logger name="org.springframework.ws.client.support.interceptor.AbstractValidatingInterceptor" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+
+        
+        <!-- 
+               Specific log level for Spring WS.
+        -->
+        <Logger name="org.springframework.ws" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+    
+               <!-- 
+               General logging Spring.
+        -->
+        <Logger name="org.springframework" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+
+               <!-- 
+                       Anything else will be using TRACE logging level.
+                -->        
+        <Root level="INFO">
             <AppenderRef ref="STDOUT"/>
         </Root>
     </Loggers>
-</Configuration>
+</Configuration>
\ No newline at end of file
index 18a4008..6ff67a4 100644 (file)
@@ -1,13 +1,73 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="trace" strict="true"
+
+<!-- 
+       status: The level of internal Log4j events that should be logged to the console.
+       Valid values for this attribute are "trace", "debug", "info", "warn", "error" and "fatal".
+       
+       monitorInterval: The minimum amount of time, in seconds, that must elapse before the file configuration is checked for changes.
+       
+       
+       see https://logging.apache.org/log4j/2.x/manual/configuration.html
+ -->
+<Configuration status="error" strict="true" monitorInterval="30"
                 name="XMLConfigTest" packages="org.apache.logging.log4j.test">
+                
+       <!--
+               ALL > TRACE > DEBUG > INFO > WARN > ERROR > OFF
+               
+               ERROR by default.
+       -->
+                
     <Appenders>
         <Appender type="Console" name="STDOUT">
             <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
         </Appender>
     </Appenders>
     <Loggers>
-        <Root level="trace">
+    
+    
+        <!-- 
+               Specific log when request message from client or response message created by this server contains validation errors.
+               It is used by org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor
+         -->
+        <Logger name="org.springframework.ws.soap.server.endpoint.interceptor.AbstractFaultCreatingValidatingInterceptor" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+        
+        
+        <!-- Specific log level for SOAP SoapEnvelopeLoggingInterceptor.
+                org.springframework.ws.soap.server.endpoint.SoapEnvelopeLoggingInterceptor
+                
+                see soap-ws.xml Spring configuration file.
+                
+                This configuration enables us to log the SOAP XML Request (received from client), Response (sent by this server) and Fault (sent by this server).
+       -->
+        <Logger name="org.springframework.ws.server.endpoint.AbstractLoggingInterceptor" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+        
+
+        
+        <!-- 
+               Specific log level for Spring WS.
+        -->
+        <Logger name="org.springframework.ws" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+    
+               <!-- 
+               General logging Spring.
+        -->
+        <Logger name="org.springframework" level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+    
+
+               <!-- 
+                       Anything else will be using TRACE logging level.
+                -->        
+        <Root level="INFO">
             <AppenderRef ref="STDOUT"/>
         </Root>
     </Loggers>
index da59eba..4badaa6 100644 (file)
        </profiles>
 
        <dependencies>
+           <!--
+               1/3 Required dependency for log4j 2 with slf4j: binding between log4j 2 and slf4j
+       -->
                <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-slf4j-impl</artifactId>
                        <version>2.3</version>
                </dependency>
+               <!--
+               2/3 Required dependency for log4j 2 with slf4j: log4j 2 maven plugin (it is the log4j 2 implementation)
+       -->
                <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-core</artifactId>
                        <version>2.3</version>
                </dependency>
+               <!-- 
+                       3/3 Required dependency for getting rid of commons logging.
+                       This is the BRIDGE (no binding) between Jakarta Commons Logging (used by Spring) and whatever
+                       I am using for logging (in this case I am using log4j 2)
+                       See: http://www.slf4j.org/legacy.html
+                       
+                       We need exclusions in every dependency using Jakarta Commons Logging (see Spring dependencies below)
+                -->
+               <dependency>
+               <groupId>org.slf4j</groupId>
+               <artifactId>jcl-over-slf4j</artifactId>
+               <version>1.7.12</version>
+               </dependency>
                <dependency>
                        <groupId>cglib</groupId>
                        <artifactId>cglib</artifactId>
                                <groupId>org.springframework.ws</groupId>
                                <artifactId>spring-ws-core</artifactId>
                                <version>${spring.ws.version}</version>
+                               <!-- 
+                                       Required dependency for getting rid of commons logging and use my own logging library
+                                       (in my case I decided to use log4j 2 under slf4j)
+                                -->
+                               <exclusions>
+                               <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
                        </dependency>
                        <dependency>
                                <groupId>org.springframework.ws</groupId>
                                <artifactId>spring-xml</artifactId>
                                <version>${spring.ws.version}</version>
+                               <!-- 
+                                       Required dependency for getting rid of commons logging and use my own logging library
+                                       (in my case I decided to use log4j 2 under slf4j)
+                                -->
+                               <exclusions>
+                               <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
                        </dependency>
                        <dependency>
                                <groupId>org.jdom</groupId>
                                <artifactId>spring-ws-test</artifactId>
                                <version>${spring.ws.version}</version>
                                <scope>test</scope>
+                               <!-- 
+                                       Required dependency for getting rid of commons logging and use my own logging library
+                                       (in my case I decided to use log4j 2 under slf4j)
+                                -->
+                               <exclusions>
+                               <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>                           
                        </dependency>
                        <dependency>
                                <groupId>org.mockito</groupId>