2 Replies Latest reply on May 20, 2015 10:23 AM by samalaraj72

    How to see Spring's logs in Wildfly ?

    mattvbv

      We have created a module with all the spring jars. This module is then used by our web application (using a dependency declaration in jboss-deployment-structure.xml).

       

      The logs in our application code using slf4j are configured using the logging subsystem and are correctly generated. However we do not get any log out of Spring itself, which is currently one of the blockers for our migration to Wildfly.

       

      Does anyone know how to get these logs being picked up by Wildfly's logging subsystem ?  Spring logging is done using commons-logging. Isn't Wildfly's logging system able to provide a logging runtime for those logs ?

       

      (We use Spring 4.1.4)

       

      Thanks,

       

      M.

        • 1. Re: How to see Spring's logs in Wildfly ?
          mattvbv

          I managed to get it working with the following configuration for the Spring module :

           

          <?xml version="1.0" encoding="UTF-8"?>
          
          
          <module xmlns="urn:jboss:module:1.3" name="io.spring.platform" slot="1.1.1.RELEASE">
          
          
              <resources>
            <resource-root path="aopalliance-1.0.jar"/>
                  <resource-root path="commons-lang-2.6.jar"/>
                  <resource-root path="spring-aop-4.1.4.RELEASE.jar"/>
                  <resource-root path="spring-beans-4.1.4.RELEASE.jar"/>
                  <resource-root path="spring-context-4.1.4.RELEASE.jar"/>
                  <resource-root path="spring-core-4.1.4.RELEASE.jar"/>
                  <resource-root path="spring-expression-4.1.4.RELEASE.jar"/>
                  <resource-root path="spring-web-4.1.4.RELEASE.jar"/>
                  <resource-root path="spring-webmvc-4.1.4.RELEASE.jar"/>
              </resources>
          
          
              <dependencies>
            <module name="javax.api"/>
            <module name="javax.servlet.jsp.api" />
            <module name="javax.servlet.jstl.api" />
            <module name="org.jboss.vfs" />
            <module name="org.apache.commons.logging"/>
            </dependencies>
          </module>
          
          

           

          With this, I know see the logs managed by the jboss logging system (do not add to active an org.springframeworg logger)  :

           

          10:57:30,428 INFO  [io.undertow.servlet] (MSC service thread 1-3) Initializing Spring root WebApplicationContext
          10:57:30,430 INFO  [io.undertow.servlet] (MSC service thread 1-6) Initializing Spring root WebApplicationContext
          10:57:30,433 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-6) Root WebApplicationContext: initialization started
          10:57:30,435 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-3) Root WebApplicationContext: initialization started
          10:57:30,545 DEBUG [org.springframework.web.context.support.StandardServletEnvironment] (MSC service thread 1-6) Adding [servletConfigInitParams] PropertySource with lowest search precedence
          ...
          10:57:31,984 DEBUG [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] (MSC service thread 1-3) Looking for URL mappings in application context: WebApplicationContext for namespace 'dispatcher-servlet-servlet': startup date [Fri Feb 27 10:57:31 CET 2015]; parent: Root WebApplicationContext
          ...
          10:57:32,873 DEBUG [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-3) Servlet 'dispatcher-servlet' configured successfully
          10:57:32,873 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017534: Registered web context: /library
          
          

           

          It is the org.apache.commons.logging dependency that does the trick. It is in fact a jcl to slf4j bridge :

           

          <module-alias xmlns="urn:jboss:module:1.3" name="org.apache.commons.logging" target-name="org.slf4j.jcl-over-slf4j"/>
          
          

           

          The logs can now be managed centrally by the jboss logging subsystem (and have their level dynamically reconfigured through the jboss-cli), and not with another application-local configuration somewhere that logs in separate files.

           

          This is a very basic Spring-platform module which loads just enough jars to run a very small web test project, to solve the migration problems one step at a time,

           

          The test project has the following jboss-deployment-structure.xml :

           

          <jboss-deployment-structure>
            <deployment>
              <dependencies>
                <module name="io.spring.platform" slot="1.1.1.RELEASE">
                <imports>
                    <include path="META-INF**" />
                  </imports>
                </module>
                <module name="com.mattvbv.demo.library.wildfly.libs" />
              </dependencies>
            </deployment>
          </jboss-deployment-structure>
          
          

           

          For the sake of completeness, the second module imported in my test project just references hsqldb :

           

          <?xml version="1.0" encoding="UTF-8"?>
          <module xmlns="urn:jboss:module:1.3" name="com.mattvbv.demo.library.wildfly.libs">
             <resources>
             <resource-root path="hsqldb-2.3.2.jar"/>
             </resources>
             <dependencies>
             </dependencies>
          </module>
          
          

           

          so there is no magic trick somewhere that resolves the Spring logging problem other than the correct spring module dependencies.

           

          The application's war file, once packaged, doesn't contain any jar.

          • 2. Re: How to see Spring's logs in Wildfly ?
            samalaraj72

            Hi Matthew,

             

            i Have same log problem in wildfly, my application is in spring,

             

            how to get the log,


            send me your solution here or to samalaraj72@gmail.com,


            Thanks in advance.