Logging

Version 3.3 by Vincent Massol on 2009/06/20
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Documentation.AdminGuide.Logging]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Logging

XWiki uses Commons Logging for logging. By default XWiki is configured so that Commons Logging uses log4J. XWiki's Log4J configuration is located inside XWiki's JAR (xwiki.jar), in a log4j.properties file. XWiki' JAR is itself located in your WEB-INF/lib/ directory.

Information

By default XWiki is configured to log everything both on the console and in a xwiki.log file located in the directory from where you have started the JVL. This is usually the directory from where you have started your application server/Servlet container. It's recommended to either start the JVM from a location where it's ok to output the xwiki.log file or to create a custom Log4J configuration as explained below.

Using a custom Log4J configuration

The best solution is to create a new log4j.properties file in your WEB-INF/classes directory. It'll thus override the one from the XWiki JAR. As an example, here's a sample configuration:

### Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%X{url}] [%t] %-5p %-30.30c{2} %x - %m %n

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=xwiki.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=50
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%X{url}] [%t] %-5p %-30.30c{2} %x - %m %n

### By default everything that is of warning or severity WARN, ERROR or FATAL is logged both to
### the console and to the xwiki.log file.
log4j.rootLogger=warn, stdout, file

### Hibernate logging options
log4j.logger.org.hibernate=warn
log4j.logger.org.hibernate.SQL=warn
log4j.logger.org.hibernate.type=warn
log4j.logger.org.hibernate.ps.PreparedStatementCache=warn

### XWiki logging configuration
log4j.logger.org.xwiki=info
log4j.logger.com.xpn.xwiki=warn
log4j.logger.com.xpn.xwiki.render.XWikiRadeoxRenderEngine=warn
log4j.logger.com.xpn.xwiki.store.migration=info

### Deactive Struts warnings
log4j.logger.org.apache.struts.util.RequestUtils=error

### Deactivate JGroups warnings
log4j.logger.org.jgroups=error

## Deactive PDF Export CSS Applier warnings
log4j.logger.info.informatica.doc.style.css.dom=error
log4j.logger.org.apache.fop.layoutmgr.inline.ContentLayoutManager=error

Refer to Log4J's documentation to understand the settings. As an example, to turn on Hibernate's calls, just set the following:

log4j.logger.org.hibernate.SQL=debug

Activating the XWiki monitoring feature

Information

The monitoring feature is already active in the default configuration.

XWiki has a feature to monitor times spent in its major components. To activate it, you need to:

  • Enable the Monitor plugin by adding/modifying the following plugin definition in the xwiki.cfg configuration file:
xwiki.plugins=\
   [...]
   com.xpn.xwiki.monitor.api.MonitorPlugin
  • Enable it by adding/modifying the following in the xwiki.cfg configuration file:
xwiki.monitor=1
  • Since the plugin logs everything under the DEBUG severity you also need to configure Log4J (as described above) by adding the following in log4j.properties:
log4j.logger.com.xpn.xwiki.monitor=debug

Get Connected