0 Replies Latest reply on Oct 18, 2012 12:24 PM by cgmedina

    Configuring log4j.properties on JBoss AS6

    cgmedina Newbie

      Hi everyone

       

      I'm trying to use a custom log4j.properties file for showing my own application messages, but I can't get it to work.

       

      Here's my log4j.properties file:

       

      # ------------------------------------------------------------------------------
      # level: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL or a custom level value.
      # ------------------------------------------------------------------------------
      # log4j.rootCategory=warn, stdout, rolling, xml, lf5, lf5r, socketLogger
      # ------------------------------------------------------------------------------
      log4j.rootCategory=DEBUG, rolling
      log4j.category.com.egt.commons=DEBUG, stdout
      log4j.additivity.com.egt.commons=true
      log4j.category.com.egt.base=DEBUG, stdout
      log4j.additivity.com.egt.base=true
      log4j.category.com.egt.core=DEBUG, stdout
      log4j.additivity.com.egt.core=true
      log4j.category.com.egt.data=DEBUG, stdout
      log4j.additivity.com.egt.data=true
      log4j.category.com.egt.ejb.business=DEBUG, stdout
      log4j.additivity.com.egt.ejb.business=true
      log4j.category.com.egt.ejb.core=DEBUG, stdout
      log4j.additivity.com.egt.ejb.core=true
      log4j.category.com.egt.ejb.persistence=DEBUG, stdout
      log4j.additivity.com.egt.ejb.persistence=true
      log4j.category.com.egt.eac.toolkit=DEBUG, stdout
      log4j.additivity.com.egt.eac.toolkit=true
      log4j.category.com.egt.ejb.toolkit=DEBUG, stdout
      log4j.additivity.com.egt.ejb.toolkit=true
      
      
      # BEGIN APPENDER: CONSOLE APPENDER (stdout)
      log4j.appender.stdout=org.apache.log4j.ConsoleAppender
      # log4j.appender.stdout.layout=org.apache.log4j.TTCCLayout
      # log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
      log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
      # log4j.appender.stdout.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss,SSS} %-5p %m%n
      # log4j.appender.stdout.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss,SSS} %-5p (%-1c{1}) %m%n
      log4j.appender.stdout.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss,SSS} | %-5p | %-16c{1} | %m%n
      # Possible information overload?
      # log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
      # additionally, some layouts can take additional information like the ConversionPattern for the PatternLayout.
      # log4j.appender.stdout.layout.ConversionPattern=%d %-5p %-17c{2} (%30F:%L) %3x - %m%n
      # END APPENDER: CONSOLE APPENDER (stdout)
      
      
      # BEGIN APPENDER: ROLLING FILE APPENDER (rolling)
      log4j.appender.rolling=org.apache.log4j.RollingFileAppender
      log4j.appender.rolling.file=log4j.appender.rolling.log
      log4j.appender.rolling.MaxFileSize=1000KB
      log4j.appender.rolling.MaxBackupIndex=2
      log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
      # log4j.appender.rolling.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss,SSS} %-5p %-30.30c{1} %m%n
      # log4j.appender.rolling.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss,SSS} %-5p (%-1.30c{1}) %m%n
      log4j.appender.rolling.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss,SSS} | %-5p | %-16c{1} | %m%n
      # Possible information overload?
      # log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
      # additionally, some layouts can take additional information like the ConversionPattern for the PatternLayout.
      # log4j.appender.stdout.layout.ConversionPattern=%d %-5p %-14.14t %-17c{2} (%30F:%L) %3x - %m%n
      # END APPENDER: ROLLING FILE APPENDER (rolling)
      
      
      # BEGIN APPENDER: XML FILE APPENDER (xml)
      # A standard file appender where we have put an XML layout onto the output
      # event records. A file put out using this technique can be loaded after
      # the fact into Chainsaw for viewing, filtering, searching, etc.
      log4j.appender.xml=org.apache.log4j.FileAppender
      log4j.appender.xml.file=log4j.appender.xml.log
      log4j.appender.xml.append=false
      log4j.appender.xml.layout=org.apache.log4j.xml.XMLLayout
      # END APPENDER: XML FILE APPENDER (xml)
      
      
      # BEGIN APPENDER: LogFactor5 APPENDER (lf5)
      # LogFactor5 is a Swing window that directly receives logging messages and
      # displays them. It offers filtering, searching etc. similar to Chainsaw or
      # Lumbermill but you don't have to use a socket appender so it should be faster
      # when the logging display is on the same machine as the program issuing
      # messages.
      log4j.appender.lf5=org.apache.log4j.lf5.LF5Appender
      log4j.appender.lf5.MaxNumberOfRecords=10000
      # END APPENDER: LogFactor5 APPENDER (lf5)
      
      
      # BEGIN APPENDER: LogFactor5 ROLLING FILE APPENDER (lf5r)
      # Like the XML appender above, this is a specialized format designed to be read
      # from a tool. In this case LogFactor5 can load up files in this format for
      # after the fact review.
      log4j.appender.lf5r=org.apache.log4j.RollingFileAppender
      log4j.appender.lf5r.file=log4j.appender.lf5r.log
      log4j.appender.lf5r.layout=org.apache.log4j.PatternLayout
      log4j.appender.lf5r.layout.ConversionPattern=[slf5s.start]%d{DATE}[slf5s.DATE]%n %p[slf5s.PRIORITY]%n%x[slf5s.NDC]%n%t[slf5s.THREAD]%n%c[slf5s.CATEGORY]%n %l[slf5s.LOCATION]%n%m[slf5s.MESSAGE]%n%n
      # END APPENDER: LogFactor5 ROLLING FILE APPENDER (lf5r)
      
      
      # BEGIN APPENDER: SOCKET APPENDER (socketLogger)
      # Note: if you don't have anything configured to accept the events
      # from the socketLogger appender, you'll see an exception on program
      # startup (to console), and occasional status messages (to console)
      # on if the log4j system has managed to connect to the specified
      # socket.
      #log4j.appender.socketLogger=org.apache.log4j.net.SocketAppender
      #log4j.appender.socketLogger.RemoteHost=localhost
      #log4j.appender.socketLogger.Port=4445
      #log4j.appender.socketLogger.LocationInfo=false
      # END APPENDER: SOCKET APPENDER (socketLogger)
      

       

      After reading this forum I tried to place the log4j.properties in the root of the ear and placing the lo4j.jar inside the lib directory of each of the war projects, I also configured jboss-app.xml for using custom classloading as follows:

       

       

      <jboss-app>
       <loader-repository>
         org.myapp:loader=MyClassLoader
         <loader-repository-config>
            java2ParentDelegation=false
         </loader-repository-config>
       </loader-repository>
      </jboss-app> 
      

       

      but it seems to ignore it.

       

      I'm using JBoss 6.0.0 Final. What am I doing wrong? I just want my application to register all event messages on the log file.

       

      thanks