Wiki source code of Logging

Last modified by Vincent Massol on 2026/07/18 22:11

Hide last authors
Manuel Smeria 12.2 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
Silvia Macovei 4.1 4
Thomas Mortagne 26.1 5 XWiki uses [[SLF4J>>http://www.slf4j.org/]] for logging. By default XWiki is configured so that SLF4J uses [[Logback>>http://logback.qos.ch/]]. XWiki's Logback configuration is located in the ##[[WEB-INF/classes/logback.xml>>https://raw.github.com/xwiki/xwiki-platform/master/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/resources/logback.xml]]## file.
Vincent Massol 1.1 6
Manuel Smeria 12.2 7 XWiki is also configured by default so that any logs generated by 3rd part JARs used by XWiki (i.e. in the XWiki classpath at runtime) will automatically find their ways to the output defined by the Logback configuration file. This is active for Apache Commons Logging (JCL) and Log4J. This is achieved by using [[a SLF4J Bridge>>http://www.slf4j.org/legacy.html]] for both logging frameworks (it's the ##log4j-over-slf4j-*.jar## and ##jcl-over-slf4j-*.jar## files that provide this feature).
Vincent Massol 11.1 8
Vincent Massol 21.1 9 = Log Location =
Vincent Massol 1.4 10
Vincent Massol 22.1 11 == Main Logs ==
12
Vincent Massol 21.1 13 By default XWiki is configured to log everything on the console only. Whether the console is captured by your Servlet Container or not depends on the container you use.
14
Eleni Cojocariu 26.4 15 Here are some potential locations you can check, depending on the [[installation method>>documentation.xs.admin.installation.methods.WebHome]] you've chosen::
Jean-Sébastien Dennebouy 23.1 16
17 * If you use the [[XWiki Debian packaging>>xwiki:Documentation.AdminGuide.Installation.InstallationViaAPT.WebHome]], and thus using Tomcat, it's in ##/var/log/tomcat*/catalina.out##
18 ** Recent Tomcat packages use service logs, visible using the command ##journalctl -u tomcat9.service##
Vincent Massol 28.2 19 * If you use the [[XWiki Docker packaging>>https://github.com/xwiki-contrib/docker-xwiki/blob/master/README.md]] there are 2 locations where the XWiki logs are (see [[the Docker logs section>>https://github.com/xwiki/xwiki-docker/blob/master/README.md#logs]] for more details):
Vincent Massol 27.1 20 ** In the console that started Tomcat, or if you started it in background, you can get them with ##docker logs <container id>##.
21 ** {{version since="16.10.19,17.10.11,18.4.3,18.6.0"}}In the permanent directory under ##logs/*##{{/version}}
Eleni Cojocariu 26.3 22 * If you use the [[XWiki Standalone packaging>>documentation.xs.admin.installation.methods.install-standalone-demo-distribution.WebHome]], then it's in the console and also in ##data/logs/<date>.output.log##.
Vincent Massol 21.1 23 * If you use the [[Manual WAR packaging>>Documentation.AdminGuide.InstallationWAR]], then it depends on the Servlet engine you've used and how you've configured it. You could check in ##/var/log/tomcat*/catalina.out## on unix or ##<tomcat home>/logs/catalina.out## for Tomcat.
24
Vincent Massol 22.1 25 == Job Logs ==
26
Thomas Mortagne 25.1 27 XWiki has the concept of [[jobs>>extensions:Extension.Job Module.WebHome]] (e.g. when you install or upgrade an Extension or when you delete pages, they all execute in a job). Very often, jobs capture the logs and output them in job log files located in the [[permanent directory>>Documentation.AdminGuide.Configuration.WebHome#HPermanentDirectory]], under the ##jobs/status## subdirectories. Log files are named ##log.xml##.
Vincent Massol 22.1 28
29 Note that some features allow you to see view these logs in the UI. For exampe the Extension Manager has a UI so that you can [[review the logs when an extension was installed, or updated>>extensions:Extension.Extension Manager Application#HProgressLog]].
30
Vincent Massol 16.1 31 = Configuring Logging =
Vincent Massol 1.1 32
Vincent Massol 14.1 33 There are various ways in which you can configure what to log.
34
Vincent Massol 17.2 35 See also the [[Logging section of the Debugging page>>dev:Community.Debugging#HLogging]] for specific details on some loggers.
Vincent Massol 17.1 36
Anca Luca 20.1 37 {{info}}
38 Of the 3 methods proposed under, only the Manual method is persistent **after a server restart**. So if your server might restart/be restarted and you want the log configuration to be kept after this restart, the only method is adding them to logback.xml.
39 {{/info}}
Anca Luca 18.1 40
Vincent Massol 16.1 41 == Manually ==
Vincent Massol 13.1 42
Anca Luca 20.1 43 Simply edit the Logback configuration file (##logback.xml## in ##WEB-INF/classes## in your web application folder) and restart the Servlet container for it to take effect.
Vincent Massol 13.1 44
Vincent Massol 16.1 45 == Using the Log Application ==
Vincent Massol 13.1 46
47 Starting with XWiki 4.2 a new [[Logging Application>>extensions:Extension.Logging Application]] is available in your wiki's administration UI and you can use it to configure the log levels for all features.
48
Anca Luca 20.1 49 == Using JMX ==
Vincent Massol 13.1 50
Antoine Mottier 24.1 51 Since XWiki 14.8 Logback no longer support JMX so you won't be able to use JMX to update your logging configuration.
52
Manuel Smeria 12.2 53 [[LogBack exposes its configuration with JMX>>http://logback.qos.ch/manual/jmxConfig.html]] making it 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.
Vincent Massol 8.1 54
Ecaterina Moraru (Valica) 20.4 55 See the [[Monitoring Guide>>Documentation.AdminGuide.Monitoring]] for more details on using JMX with XWiki.
Vincent Massol 8.1 56
Vincent Massol 16.1 57 = Analyzing logs with Lilith =
Vincent Massol 9.1 58
59 [[Lilith>>http://lilith.huxhorn.de/]] is a logging and access event viewer. It makes it easy to analyze large quantities of logs. To use it, configure XWiki's Logging to send events to the Socket appender. Add the following to the ##logback.xml## file:
60
61 {{code language="xml"}}
62 ...
63 <appender name="socket" class="ch.qos.logback.classic.net.SocketAppender">
64 <RemoteHost>localhost</RemoteHost>
65 <Port>4560</Port>
66 <ReconnectionDelay>170</ReconnectionDelay>
67 <IncludeCallerData>true</IncludeCallerData>
68 </appender>
69 ...
70 {{/code}}
71
72 And add the new appender to the list of appenders to use. For example:
73
74 {{code language="xml"}}
75 ...
76 <root level="warn">
Jean-Sébastien Dennebouy 23.1 77 <appender-ref ref="stdout"></appender-ref>
78 <appender-ref ref="socket"></appender-ref>
Vincent Massol 9.1 79 </root>
80 ...
81 {{/code}}
82
83 Open Lilith (it's a desktop application) and it'll automatically listen on port 4560 so when you start XE you'll see its logs show up in Lilith.
84
85 For example:
86
Jean-Sébastien Dennebouy 23.1 87 [[image:lilith.png||width="950"]]
Vincent Massol 9.1 88
Vincent Massol 11.1 89 == Using a different SLF4J implementation ==
90
Thomas Mortagne 15.1 91 If you wish, for example, to use Log4J to log all logs produced by XWiki you can do so by doing the following ([[described in the SLF4J manual>>http://www.slf4j.org/manual.html]]):
Anca Luca 20.1 92
Manuel Smeria 12.2 93 * Remove the Logback SLF4J implementation from the classpath by removing ##WEB-INF/lib/logback-classic-*.jar## and ##WEB-INF/lib/logback-core-*.jar##
94 * Remove the Log4J over SLF4J JAR from the classpath by removing ##WEB-INF/lib/log4j-over-slf4j-*.jar##
Vincent Massol 11.2 95 * Add the Log4J SLF4J implementation to the classpath: ##slf4j-log4j*-*.jar##
96 * Add Log4J itself to the classpath
Vincent Massol 11.1 97
Vincent Massol 16.1 98 = Older XWiki versions =
Vincent Massol 8.1 99
Vincent Massol 16.1 100 XWiki versions 3.0 and older use Commons Logging for logging. By default XWiki was configured so that Commons Logging was using log4J. XWiki's Log4J configuration was located inside XWiki's JAR (xwiki-core-x.y.jar), in a ##[[log4j.properties>>https://raw.github.com/xwiki/xwiki-platform/13e01088e74c170452088a56fe54fb76a7ecb041/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/log4j.properties]]## file. XWiki' JAR is itself located in your ##WEB-INF/lib/## directory.
Vincent Massol 8.1 101
102 {{info}}
Vincent Massol 16.1 103 By default XWiki was configured to log everything on the console only.
Vincent Massol 8.1 104 {{/info}}
105
106 == Using a custom Log4J configuration ==
107
Vincent Massol 16.1 108 The best solution was 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:
Vincent Massol 1.1 109
Silvia Macovei 4.1 110 {{code language="none"}}
Vincent Massol 1.6 111 ### Direct log messages to stdout
Vincent Massol 1.1 112 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
113 log4j.appender.stdout.Target=System.out
114 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
Vincent Massol 3.3 115 log4j.appender.stdout.layout.ConversionPattern=%d [%X{url}] [%t] %-5p %-30.30c{2} %x - %m %n
Vincent Massol 1.1 116
Vincent Massol 1.6 117 ### By default everything that is of warning or severity WARN, ERROR or FATAL is logged both to
118 ### the console and to the xwiki.log file.
Jerome 6.1 119 log4j.rootLogger=warn, stdout
Vincent Massol 1.1 120
Vincent Massol 1.6 121 ### Hibernate logging options
Vincent Massol 1.1 122 log4j.logger.org.hibernate=warn
123 log4j.logger.org.hibernate.SQL=warn
124 log4j.logger.org.hibernate.type=warn
125 log4j.logger.org.hibernate.ps.PreparedStatementCache=warn
126
Vincent Massol 1.6 127 ### XWiki logging configuration
Vincent Massol 3.3 128 log4j.logger.org.xwiki=info
Vincent Massol 1.1 129 log4j.logger.com.xpn.xwiki=warn
130 log4j.logger.com.xpn.xwiki.render.XWikiRadeoxRenderEngine=warn
Vincent Massol 2.1 131 log4j.logger.com.xpn.xwiki.store.migration=info
Vincent Massol 1.1 132
Vincent Massol 2.1 133 ### Deactive Struts warnings
Vincent Massol 1.1 134 log4j.logger.org.apache.struts.util.RequestUtils=error
135
Vincent Massol 1.6 136 ### Deactivate JGroups warnings
Vincent Massol 1.1 137 log4j.logger.org.jgroups=error
Vincent Massol 2.1 138
139 ## Deactive PDF Export CSS Applier warnings
140 log4j.logger.info.informatica.doc.style.css.dom=error
141 log4j.logger.org.apache.fop.layoutmgr.inline.ContentLayoutManager=error
Silvia Macovei 4.1 142 {{/code}}
Vincent Massol 1.1 143
144 Refer to Log4J's documentation to understand the settings. As an example, to turn on Hibernate's calls, just set the following:
145
Silvia Macovei 4.1 146 {{code}}
Vincent Massol 1.1 147 log4j.logger.org.hibernate.SQL=debug
Silvia Macovei 4.1 148 {{/code}}
Vincent Massol 1.1 149
Vincent Massol 8.1 150 = Activating the XWiki Monitoring feature =
Vincent Massol 3.1 151
Silvia Macovei 4.1 152 {{info}}
153 The monitoring feature is already active in the default configuration.
154 {{/info}}
Vincent Massol 3.1 155
156 XWiki has a feature to monitor times spent in its major components. To activate it, you need to:
157
Anca Luca 20.1 158 * Enable the Monitor plugin by adding/modifying the following plugin definition in the ##xwiki.cfg## configuration file:(((
Silvia Macovei 4.1 159 {{code language="none"}}
Vincent Massol 3.1 160 xwiki.plugins=\
161 [...]
162 com.xpn.xwiki.monitor.api.MonitorPlugin
Silvia Macovei 4.1 163 {{/code}}
Manuel Smeria 12.2 164 )))
Anca Luca 20.1 165 * Enable it by adding/modifying the following in the ##xwiki.cfg## configuration file:(((
Silvia Macovei 4.1 166 {{code language="none"}}
Vincent Massol 3.1 167 xwiki.monitor=1
Silvia Macovei 4.1 168 {{/code}}
Manuel Smeria 12.2 169 )))
Anca Luca 20.1 170 * 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.(((
Vincent Massol 8.1 171 For example for Logback it means adding the following in ##logback.xml##:
172
Silvia Macovei 4.1 173 {{code language="none"}}
Jean-Sébastien Dennebouy 23.1 174 <logger name="com.xpn.xwiki.monitor" level="debug"></logger>
Vincent Massol 8.1 175 {{/code}}
176
177 And for older XWiki versions using Log4J it means adding the following in ##log4j.properties##:
178
179 {{code language="none"}}
Vincent Massol 3.1 180 log4j.logger.com.xpn.xwiki.monitor=debug
Silvia Macovei 4.1 181 {{/code}}
Vincent Massol 8.1 182 )))

Get Connected