Logs Configuration
1 Introduction
In order to accommodate to the different target runtime where it can be deployed, eXo is capable of leveraging several logging systems. eXo let's you choose the underlying logging engine to use and even configure that engine (as a quick alternative to doing it directly in your runtime environment). The currently supported logging engines are :- Apache Log4J
- JDK's logging
- Apache Commons logging (which is itself a pluggable logging abstraction)
2 Logs configuration initializer
eXo lets you choose whatever logging engine you want as this is generally influences by the AS runtime or internal policy. This is done through an eXo component called LogConfigurationInitializer. org.exoplatform.services.log.LogConfigurationInitializer that reads init parameters and configures logging system according to them. The parameters:- configurator - an implementation of the LogConfigurator interface with one method configure() that accepts a list of properties (3rd init parameter) to configure the underlying log system using the concrete mechanism. Again there are three configurators for the most known log systems (commons, log4j, jdk).
- properties - properties to configure the concrete log system (system properties for commons, log4j.properties or logging.properties for commons, log4j and jdk respectively) Look at the configuration examples below.
- logger - an implementation of commons-logging Log interface. It is possible to use commons wrappers but to support buffering required by the log portlet three kinds of loggers were added: BufferedSimpleLog, BufferedLog4JLogger and BufferedJdk14Logger (they contain BufferedLog and extend SimpleLog, Log4JLogger and Jdk14Logger commons-logging wrappers respectively).
3 Configuration examples
On products built on top of Portal 2.5+, the default logs configuration sits in portal.war/WEB-INF/conf/common/logs-configuration.xml Below are some sample configurations for the most common logging engines.3.1 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>logger</name>
<value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
</value-param>
<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>
3.2 JDK Logging
JDK logging (aka JUL) is the builtin logging framework introduced in JDK 1.4. It is a good option for Tomcat AS.- edit the variable LOG_OPTS in your eXo.sh/eXo.bat :
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>logger</name>
<value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
</value-param>
<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>
3.3 Commons Logging SimpleLog
SimpleLog is a minimal logging system distributed with Commons Logging. To be used when nothing else is available or when you seek simplicity.
<component>
<type>org.exoplatform.services.log.LogConfigurationInitializer</type>
<init-params>
<value-param>
<name>logger</name>
<value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
</value-param>
<value-param>
<name>configurator</name>
<value>org.exoplatform.services.log.impl.SimpleLogConfigurator</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>
4 Tips and Troubleshooting
4.1 JBoss tips
If you use log4j configuration, you can change the log configuration directly at runtime in: JBOSS_HOME/server/default/conf/jboss-log4j.xml.- To enable debug logs :
<param name="Threshold" value="DEBUG"/>
- To exclude messages from unnecessary classes (server's internal) modify the threshold of these classes to "FATAL".
- If you are using a Logger other than log4j, you have to remove log4j*.jar from your classpath
on 07/09/2009 at 15:22