1 Reply Latest reply on Jun 27, 2006 10:18 PM by ddieterle

    Log4j and JBoss web app

      I was wondering if anyone could give me insight into why I am unable to have my web application put logging information into a separate file?


      Below are the settings I am using for log4j.

      From server\default\conf\jboss-service.xml:

      <!-- ==================================================================== -->
       <!-- Log4j Initialization -->
       <!-- ==================================================================== -->
      
       <mbean code="org.jboss.logging.Log4jService"
       name="jboss.system:type=Log4jService,service=Logging"
       xmbean-dd="resource:xmdesc/Log4jService-xmbean.xml">
       <attribute name="ConfigurationURL">resource:jboss-log4j.xml[</attribute>
       <!-- Set the org.apache.log4j.helpers.LogLog.setQuiteMode. As of log4j1.2.8
       this needs to be set to avoid a possible deadlock on exception at the
       appender level. See bug#696819.
       -->
       <attribute name="Log4jQuietMode">true</attribute>
       <!-- How frequently in seconds the ConfigurationURL is checked for changes -->
       <attribute name="RefreshPeriod">60</attribute>
       </mbean>
      



      From server\default\conf\jboss-log4j.xml:

      <!-- ========================================================= -->
       <!-- Preserve messages in a local file for AdvPlan application -->
       <!-- ========================================================= -->
       <appender name="AdvPlanLog" class="org.apache.log4j.FileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="Append" value="false"/>
       <param name="File" value="${jboss.server.home.dir}/log/AdvPlan.log"/>
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
       </layout>
       </appender>
      
      <!-- ======================================== -->
       <!-- Limit categories for AdvPlan application -->
       <!-- ======================================== -->
      
       <category name="com.lmco.lever">
       <priority value="DEBUG"/>
       <appender-ref ref="AdvPlanLog"/>
       </category>
      



      From applications log4j.properties file in the applications classes directory:

      log4j.rootCategory=, dest1
      #log4j.category.TestLogging=DEBUG, dest2
      #log4j.category.AdvPlanLog=DEBUG, AdvPlanLog
      log4j.category.AdvPlanLog=DEBUG, dest2
      #log4j.rootCategory=DEBUG, AdvPlanLog
      #DEBUG, dest1 INFO WARN ERROR FATAL
      log4j.appender.dest1=org.apache.log4j.ConsoleAppender
      #log4j.appender.dest1.layout=org.apache.log4j.SimpleLayout
      log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
      #log4j.appender.dest1.layout.ConversionPattern=%-5p %l %x: %m%n

      #See http://logging.apache.org/log4j/docs/manual.html
      log4j.appender.dest1.layout.ConversionPattern=%r [%t] %-5p %c - %m%n
      #Example output
      #176 [main] INFO org.foo.Bar - Located nearest gas station.

      ! WRITE LOG TO A FILE, ROLL THE FILE EVERY WEEK
      log4j.appender.dest2=org.apache.log4j.DailyRollingFileAppender
      ! Specify the file name
      log4j.appender.dest2.File=F:/EnterpriseLogistics/jboss-portal-2.0-jboss-4.0.2/server/default/log/AdvPlan.log
      ! Control the maximum log file size
      #log4j.appender.dest2.MaxFileSize=500KB
      ! Rollover log file at the start of each week
      log4j.appender.dest2.DatePattern='.'yyyy-ww
      ! Specify the pattern of the output of the logger
      log4j.appender.dest2.layout=org.apache.log4j.PatternLayout
      log4j.appender.dest2.layout.ConversionPattern=%r [%t] %-5p %c - %m%n


      Call in the code to get the logger:

      private static Logger log = Logger.getLogger("AdvPlanLog");


      All of my logging statements are debug level.

      Thanks,
      Dave (logging newbie)