4 Replies Latest reply on Oct 9, 2013 5:13 AM by naga.karri.fr

    log4j not working for the framework packages.

    naga.karri.fr

      I am using jboss-eap-6.1 with following apis/frameworks.

       

      jdk1.7.0_21

      apache-maven-3.0.5

      cxf 2.6.6

      spring 3.0.6.RELEASE

       

       

      I have developed a RESTful service using apache cxf and my application log4j.xml is inside the war file under WEB-INF/classes. My war contains all the dependency jars (cxf, spring etc) inside WEB-INF/lib. I am deploying the war file into jboss-eap-6.1\standalone\deployments.

      The problem I am facing is with logging of frameworks specific packages. Framework logging (cxf, spring etc) not working (does not log anything in log file) if I specify the root package for example org.apache.cxf, org.springframework. But it only workswhen I specify full package name with class name, like org.apache.cxf.interceptor.LoggingInInterceptor. However the logging works for my application specific root packages for example com.mycompany.service.inventory.

       

      But I want to be able to log framework specific logging by specifying the root packages. Any help is much appreciated.

      Below is my log4j.xml

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">

      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

      <appender name="AppLogAppender" class="org.apache.log4j.DailyRollingFileAppender">

        <param name="file"

         value="${jboss.server.log.dir}/inventory-service.log" />

        <param name="DatePattern" value="'.'yyyy-MM-dd" />  

        <param name="Append" value="true" />

        <layout class="org.apache.log4j.PatternLayout">

         <param name="ConversionPattern" value="%-5p %d [%t] %c: %m%n" />

        </layout>

      </appender>

      <category name="org.apache.cxf">

        <priority value="INFO" />

        <appender-ref ref="AppLogAppender" />

      </category>

      <category name="org.springframework">

        <priority value="INFO" />

        <appender-ref ref="AppLogAppender" />

      </category>

      <category name="com.mycompany.service.inventory">

        <priority value="INFO" />

        <appender-ref ref="AppLogAppender" />

      </category>

      <root>

        <priority value="INFO" />

        <appender-ref ref="AppLogAppender" />

      </root>

      </log4j:configuration>

       

       

       


        • 1. Re: log4j not working for the framework packages.
          jamezp

          You likely need to exclude the servers log4j dependency and set the org.jboss.as.logging.per-deployment system property to false.

           

          --

          James R. Perkins

          1 of 1 people found this helpful
          • 2. Re: log4j not working for the framework packages.
            naga.karri.fr

            Hi James, Thanks for your reponse. It was really helpful. I have done the following changes.

            1. Excluded log4j by configuring jboss-deployment-structure.xml

            <?xml version="1.0" encoding="UTF-8"?>

            <jboss-deployment-structure>

            <deployment>

              <dependencies>

               <module name="com.hcpuk.configuration" />

              </dependencies>

              <exclusions>

               <module name="org.apache.log4j" />     

              </exclusions> 

            </deployment>

            </jboss-deployment-structure>

             

            2. Set the following system property using CLI

            /system-property=org.jboss.as.logging.per-deployment:add(value=false)

             

             

            Now I can see the framework package level (for example org.apache.cxf) logging in standalone/log/server.log. My application logging is being logged in myapp-service.log. But I want to have framework logging in mypp-service.log instead of server.log.

            Am I missing anything here?

             

             

             

            Thanks,

            Naga

            • 3. Re: log4j not working for the framework packages.
              jamezp

              Because the server logging happens from a different module and class loader there is no way currently to make that work. Unless you package the framework in your application which I'm not sure you can do with CFX since it's a server dependency. You might be able to, I just haven't ever tried.

               

              --

              James R. Perkins

              1 of 1 people found this helpful
              • 4. Re: log4j not working for the framework packages.
                naga.karri.fr

                Thank you James, that explains it.