4 Replies Latest reply on Jun 11, 2012 7:57 AM by Wolf-Dieter Fink

    Application logging in server.log though application logs are seperated.

    Harika Yada Newbie

      Hi, I have just started working with jboss. I had to separate application logs using the monolithic jboss-log4j.xml in jboss/conf. It is working fine except that the application log is also logged in the server log. What change has to be done to stop the application specific logging to be present in the server log? For separating the logs, i have followed the procedure as mentioned in the link : https://community.jboss.org/wiki/SeparatingApplicationLogs

      I use Jboss5.0.1GA and my application is .war file. Please help!

       

      Here is what i have added in my jboss-log4j.xml :

       

      <appender name="ABCWAR" class="org.apache.log4j.FileAppender">

            <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"></errorHandler>

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

            <param name="File" value="${jboss.server.home.dir}/log/ABCLog.log"/>

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

              <param name="ConversionPattern" value="%d %-5p %c{1} %m%n"/>

            </layout>

            <filter class="org.jboss.logging.filter.TCLMCFilter">

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

               <!-- value="app1.war" is incorrect. -->

               <param name="DeployURL" value="ABC.war"/>

            </filter>

              <!-- end the filter chain here -->

            <filter class="org.apache.log4j.varia.DenyAllFilter"></filter>

       

         </appender>

      .......

       

      <root>

            <appender-ref ref="CONSOLE"/>

            <appender-ref ref="FILE"/>

             <appender-ref ref="ABCWAR"/>

       

         </root>

        • 1. Re: Application logging in server.log though application logs are seperated.
          Wolf-Dieter Fink Master

          This config log all into all files, thats not what you try to do.

           

          Add:

          <category name="x.y.z">  <==== your package or log-category

            <priority value="TRACE" />

            <appender-ref ref="ABCWAR"/>

          </category>

           

          This should be before the <root> and remove the appender-ref from root, thats it.

           

          If you want to have the JBoss classes in your logfile then you have to add a filter to the FILE appender that have AcceptOnMatch=false.

          But this will be a performance and lock contention issue.

          The reason is that the category is checked before the log statement is executed.

          The appender filter is inside the file-write-sync-block and you will have locking contention in case of high traffic!

           

          So if you only want to have a business logging of your app use the category.

          In case of analyzing problems I would recommend to add the FILE appender to your category and use the server.log for this.

          1 of 1 people found this helpful
          • 2. Re: Application logging in server.log though application logs are seperated.
            Harika Yada Newbie

            Thank you Fink.

             

            I have added the category tag and removed the appender-ref from the root tag as mentioned by you.

            I have got a new issue now, the server log is updated as usual by all the application logs too while the application logs are empty.

            Will you please tell me why this is happening?

             

            These are categories I have added :

             

            <category name="com.abc.rest.constants" >

                <priority value="DEBUG" />

                <appender-ref ref="ABCWAR" />

               </category>

               <category name="com.abc.rest.output" >

                <priority value="DEBUG" />

                <appender-ref ref="ABCWAR" />

               </category>

                <category name="com.abc.rest.service.application" >

                <priority value="DEBUG" />

                <appender-ref ref="ABCWAR" />

               </category>

               <category name="com.abc.rest.service.dbhandler" >

                <priority value="DEBUG" />

                <appender-ref ref="ABCWAR" />

               </category>

            ...............

             

            <root>

                  <appender-ref ref="CONSOLE"/>

                  <appender-ref ref="FILE"/>

            </root>

            • 3. Re: Application logging in server.log though application logs are seperated.
              nibuneganesh Newbie

              Hi,

               

              Is <appender-ref ref="userAppender"/> is working in  Jboss 7.1

              • 4. Re: Application logging in server.log though application logs are seperated.
                Wolf-Dieter Fink Master

                no it's different, see the logging subsystem in the configuration.

                You have to add a <logger> element with a <handlers> element and add your own file/console handler.