Logging
For XWiki 3.1 and beyond
Starting with version 3.1 XWiki logs using SLF4J. By default XWiki is configured so that SLF4J uses Logback. XWiki's Logback configuration is located in the WEB-INF/classes/logback.xml file.
To customize the Logback configuration simply edit the file and restart the Servlet container for it to take effect.
Using JMX to change the logging configuration
LogBack exposes its configuration with JMX and thus it's possible to use a JMX console to modify the logging configuration at runtime, thus not needing to restart the Servlet container. This is very useful in production when needing to debug an issue.
See the Monitoring Guide for more details on using JMX with XWiki.
For older XWiki versions
XWiki versions 3.0 and older use 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-core-x.y.jar), in a log4j.properties file. XWiki' JAR is itself located in your WEB-INF/lib/ directory.
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:
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
### 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
### 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:
Activating the XWiki Monitoring feature
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:
[...]
com.xpn.xwiki.monitor.api.MonitorPlugin
- Enable it by adding/modifying the following in the xwiki.cfg configuration file:
- Since the plugin logs everything under the DEBUG severity you also need to configure the XWiki Logging (as described above) by setting the com.xpn.xwiki.monitor category to the DEBUG level.
For example for Logback it means adding the following in logback.xml:
And for older XWiki versions using Log4J it means adding the following in log4j.properties:
log4j.logger.com.xpn.xwiki.monitor=debug