0 Replies Latest reply on Jan 17, 2012 11:50 AM by andeisen

    Problems with log4j appender (perf4j) in JBossAS 6.1.0Final

    andeisen

      Hello,

       

      I spent some time to figure out how to enable log4j-appenders in the jboss-logging.xml configuration on 6.1.0Final. Basically the fixes provided by https://issues.jboss.org/browse/JBAS-8791 worked for me. But I still have some problems:

      I would like to enable the perf4j-logging for my EJBs. For that, I need a log4j-appender ( org.perf4j.log4j.AsyncCoalescingStatisticsAppender ) that logs the collected performance statements asynchronously to an output file. For that, the statements are buffered and redirected to a fileappender.

      My current configuration is:

       

       

        <log4j-appender name="CoalescingStatistics"
                    class="org.perf4j.log4j.AsyncCoalescingStatisticsAppender">
              <level name="DEBUG"/>
              
              <!--
                The TimeSlice option is used to determine the time window for which
                all received StopWatch logs are aggregated to create a single
                GroupedTimingStatistics log. Here we set it to 10 seconds, overriding
                the default of 30000 ms
              -->
              <!-- old: <param name="TimeSlice" value="10000"/>-->
              <properties>
                <property name="timeSlice">5000</property>
              </properties>
              <!--old: <appender-ref ref="fileAppender"/>-->
              <sub-handlers>
                <handler-ref name="perf4jFile"/>
              </sub-handlers>
          </log4j-appender>
      

       

      The perf4jFile-appender is just a log4j FileAppender, which is defined by that code:

       

       

      <!-- create new FileAppender for log4j - to use with CoalescingStatisticsAppender
              of perf4j
          -->
          <log4j-appender name="perf4jFile" class="org.apache.log4j.DailyRollingFileAppender">
            <error-manager>
               <only-once/>
            </error-manager>
      
            <level name="DEBUG"/>
          
         <properties>
               <property name="datePattern">'.'yyyy-MM-dd</property>
               <property name="file">${jboss.server.log.dir}/perf4jFile.log</property>
               <property name="append">true</property>
          </properties>
      
            <formatter>
               <pattern-formatter pattern="%m%n"/>
            </formatter>
         </log4j-appender>
      

       

       

      If I use the perf4jFile-appender directly by writing this:

       

      <logger category="org.perf4j.TimingLogger" use-parent-handlers="false">
            <level name="DEBUG"/>
            <handlers>
              <!--<handler-ref name="CoalescingStatistics"/>-->
              <handler-ref name="CONSOLE"/>
              <handler-ref name="perf4jFile"/>
            </handlers>
        </logger>
      

       

      it works - the perf4j logging statements are written toe to perf4jFile output file. If I uncomment the CoalescingStatistics-appender like this:

       

       

      <logger category="org.perf4j.TimingLogger" use-parent-handlers="false">
            <level name="DEBUG"/>
            <handlers>
              <handler-ref name="CoalescingStatistics"/>
              <handler-ref name="CONSOLE"/>
              <!--<handler-ref name="perf4jFile"/>-->
            </handlers>
        </logger>
      

       

       

      nothing happens.

       

      My question now: Is the source code of log4j-appender name="CoalescingStatistics ok, or is there another way to deal with the log4j attribute "appender-ref"?

       

      Many thanks in advance!