Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Include an ApplicationLog4jConfigurationGBean in your application plan, like this:
    Code Block
        <gbean name="DirectoryLog4jConfiguration" class="org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean">
            <attribute name="log4jFile">var/directory/log4j.properties</attribute>
            <reference name="ServerInfo"><name>ServerInfo</name></reference>
        </gbean>
    
    You can also use a log4j.properties file in your classpath, but for example, in WEB-INF/classes/META-INF. (If you prefer not to place this file under WEB-INF/classes/, the path of this file must be added to your classpath). But this will obstruct anyone trying to configure logging as the file will remain packed in your application somewhere hard to find:
    Code Block
        <gbean name="DirectoryLog4jConfiguration" class="org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean">
            <attribute name="log4jResource">META-INF/log4j.properties</attribute>
        </gbean>
    
  2. Configure application specific logging in your log4j.properties file. The gbean prevents you from overriding settings that apply to global logging, but you can configure appenders for specific loggers for your application. Here's the example for ApacheDS:
    Code Block
    #attach an appender to the base apacheds package logger:
    log4j.logger.org.apache.directory=INFO,apacheds
    #do not log apacheds to geronimo logs:
    log4j.additivity.org.apache.directory=false
    
    #Configure the apacheds specific appender:
    log4j.appender.apacheds=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.apacheds.File=${org.apache.geronimo.server.dir}/var/log/apacheds.log
    log4j.appender.apacheds.layout=org.apache.log4j.PatternLayout
    # geronimo style logging
    log4j.appender.apacheds.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
    
    # some settings for the apacheds loggers, taken from the standard apacheds log4j.properties file.
    # with these we'll not get innundated when switching to DEBUG
    log4j.logger.org.apache.directory.shared.ldap.name=WARN
    #log4j.logger.org.springframework=WARN
    log4j.logger.org.apache.directory.shared.codec=WARN
    log4j.logger.org.apache.directory.shared.asn1=WARN
    

...