1.14.2. Configuration examples

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

Log4J

Log4J is a very popular and flexible logging system. It is a good option for JBoss.


  <component>
    <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
    <init-params>
      <value-param>
        <name>configurator</name>
        <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
      </value-param>
      <properties-param>
        <name>properties</name>
        <description>Log4J properties</description>
        <property name="log4j.rootLogger" value="DEBUG, stdout, file"/>
        <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender"/>
        <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout"/>
        <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d {dd.MM.yyyy HH:mm:ss} %c {1}: %m (%F, line %L) %n"/>
        <property name="log4j.appender.file" value="org.apache.log4j.FileAppender"/>
        <property name="log4j.appender.file.File" value="jcr.log"/>
        <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout"/>
        <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} %m (%F, line %L) %n"/>
      </properties-param >
    </init-params>
  </component>

Assigning logger level for classes or components

You can set logger level for class or group of classes by setting the next property:


<property name="log4j.category.{component or class name}" value="DEBUG"/>

For example:

  • We want to log all debug messages for the org.exoplatform.services.jcr.impl.core.SessionDataManager class that lies in the exo.jcr.component.core component:


<property name="log4j.category.exo.jcr.component.core.SessionDataManager" value="DEBUG"/>
  • Or we want to log all debug messages for all classes in the exo.jcr.component.core component:


<property name="log4j.category.exo.jcr.component.core" value="DEBUG"/>
  • Or we want to log all messages for all Kernel components:


<property name="log4j.category.exo.kernel" value="DEBUG"/>

JDK Logging

JDK logging (aka JUL) is the built-in logging framework introduced in JDK 1.4. It is a good option for Tomcat AS.

  • Set the System properties LOG_OPTS:

LOG_OPTS="-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger"
  • Edit your logs-configuration.xml:


<component>
    <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
    <init-params>
      <value-param>
        <name>configurator</name>
        <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
      </value-param>
      <properties-param>
        <name>properties</name>
        <description>jdk1.4 Logger properties</description>
        <property name="handlers" value="java.util.logging.ConsoleHandler"/>
        <property name=".level" value="FINE"/>
        <property name="java.util.logging.ConsoleHandler.level" value="FINE"/>
      </properties-param>
    </init-params>
  </component>

Commons Logging SimpleLog

SimpleLog is a minimal logging system distributed with Commons Logging. This is used when nothing else is available or when you seek simplicity.


  <component>
    <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
    <init-params>
      <value-param>
        <name>configurator</name>
        <value>org.exoplatform.services.log.impl.SimpleExoLogConfigurator</value>
      </value-param>
      <properties-param>
        <name>properties</name>
        <description>SimpleLog properties</description>
        <property name="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
        <property name="org.apache.commons.logging.simplelog.showdatetime" value="true"/>
      </properties-param>
    </init-params>
  </component>
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus