Wiki source code of Logging

Last modified by superadmin on 2026/11/24 18:44

Hide last authors
Eleni Cojocariu 1.1 1 XWiki writes its log records through [[SLF4J>>https://www.slf4j.org/]], backed by [[Logback>>https://logback.qos.ch/]] by default, and the bundled [[Logging Application>>doc:extensions:Extension.Logging Application]] lists every registered logger in the wiki administration. That application is the user interface of the [[Logging Module>>doc:extensions:Extension.Logging Module]], the component that lists those loggers and applies the levels you set.
2
3 The configuration that decides what is written, and where, is the {{scm path="xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/resources/logback.xml"}}##logback.xml##{{/scm}} file of the deployed web application.
4
5 == How XWiki Collects Logs ==
6
7 {{plantuml}}
8 @startuml
9 skinparam componentStyle rectangle
10 left to right direction
11
12 component "**XWiki**\norg.xwiki, com.xwiki,\ncom.xpn.xwiki" as XWIKI
13 component "**Apache Commons Logging**" as JCL
14 component "**Log4j 1.x**" as L41
15 component "**Log4j 2**" as L42
16 component "**java.util.logging**\nLucene, behind Solr" as JUL
17
18 component "**SLF4J**\nthe logging facade" as SLF4J
19 component "**Logback**\nthe default provider" as LOGBACK
20 component "**Appenders**\nthe console, by default" as OUT
21
22 file "**logback.xml**\nlevels and appenders,\nkept across restarts" as CONF
23 component "**Logging Application**\nlevels, until the\nnext restart" as APP
24
25 XWIKI --> SLF4J
26 JCL --> SLF4J : jcl-over-slf4j
27 L41 --> SLF4J : log4j-over-slf4j
28 L42 --> SLF4J : log4j-to-slf4j
29 JUL --> SLF4J : jul-to-slf4j
30 SLF4J --> LOGBACK
31 LOGBACK --> OUT
32 CONF ..> LOGBACK
33 APP ..> LOGBACK
34 @enduml
35 {{/plantuml}}
36
37 Every library on XWiki's runtime classpath ends up in that same output, whichever logging framework it was written against: XWiki ships an SLF4J bridge for Apache Commons Logging, for Log4j 1.x and for Log4j 2, so none of them needs a configuration file of its own. {{version since="18.10.0RC1"}}The same holds for ##java.util.logging##, used by Lucene behind Solr. Unless a bridge is already installed, XWiki installs one at start-up in place of the handlers of the ##java.util.logging## root logger, so that records are not printed twice, and puts those handlers back when it stops. The ##LevelChangePropagator## declared in the Logback configuration applies the levels you configure there to the ##java.util.logging## loggers, so they stop producing records for levels you disabled.{{/version}}
38
39 == Where the Logs Go ==
40
41 The shipped Logback configuration declares a single console appender, so XWiki itself writes nowhere else. [[Log File Locations>>doc:documentation.xs.admin.logging.file-locations.WebHome]] gives the file each installation method captures that console into.
42
43 Long operations run as jobs, and a job keeps a log of its own beside the main one.
44
45 == Changing What Is Logged ==
46
47 There are two ways to change a logger's level, and they differ in one respect that matters more than the rest: **only a change made in the Logback configuration file survives a restart**.
48
49 * [[Configure Log Levels>>doc:documentation.xs.admin.logging.configure-levels.WebHome]] edits ##logback.xml##, and takes effect at the next restart.
50 * [[Change Log Levels at Runtime>>doc:documentation.xs.admin.logging.change-levels-runtime.WebHome]] uses the Logging Application, and takes effect at once, which is what you want while reproducing a problem.
51
52 A logger is named after a Java package or class, and a level set on a package applies to everything below it: ##org.xwiki## and ##com.xwiki## cover XWiki's own components, ##com.xpn.xwiki## its older code base, and ##org.hibernate## the database layer.
53
54 == Going Further ==
55
56 * [[Analyze Logs with Lilith>>doc:documentation.xs.admin.logging.analyze-lilith.WebHome]] streams the records to a desktop viewer built for large volumes of log events.
57 * [[Replace Logback with Another SLF4J Provider>>doc:documentation.xs.admin.logging.replace-logback.WebHome]] swaps the backend for a different one.
58 * [[Monitor Component Execution Times>>doc:documentation.xs.admin.logging.monitor-execution-times.WebHome]] turns on the per-request timings XWiki can record for its major components.

Get Connected