Wiki source code of Configure Log Levels

Last modified by Eleni Cojocariu on 2026/11/24 18:38

Show last authors
1 Change which messages XWiki writes to [[its log>>doc:documentation.xs.admin.logging.file-locations.WebHome]] by editing the Logback configuration file, the only place where a level survives a restart.
2
3 1. Open the Logback configuration file. It is ##WEB-INF/classes/logback.xml## inside the deployed web application, except on a Debian or Ubuntu package, where that path is a symbolic link and the file to edit is ##/etc/xwiki/logback.xml##, which a package upgrade leaves alone.(((
4 {{code language="none"}}
5 /var/lib/tomcat11/webapps/xwiki/WEB-INF/classes/logback.xml a .war deployment on Tomcat
6 webapps/xwiki/WEB-INF/classes/logback.xml the standalone distribution
7 /etc/xwiki/logback.xml a Debian or Ubuntu package
8 {{/code}}
9 )))
10 1. Look at the loggers the file already declares, so that you change one rather than add a second declaration of it. The shipped configuration keeps the root logger at ##warn##, raises XWiki's own components to ##info##, and silences a few libraries that are noisy by default.(((
11 {{code language="xml"}}
12 <root level="warn">
13 <appender-ref ref="stdout"/>
14 </root>
15
16 <logger name="org.xwiki" level="info"/>
17 <logger name="com.xwiki" level="info"/>
18 <logger name="com.xpn.xwiki" level="warn"/>
19 <logger name="org.hibernate" level="warn"/>
20 <logger name="org.hibernate.SQL" level="warn"/>
21 {{/code}}
22 )))
23 1. Set the level you want on the logger you want, naming it [[as precisely as the package tree allows>>doc:documentation.xs.admin.logging.WebHome]]. The levels, from most to least verbose, are ##trace##, ##debug##, ##info##, ##warn## and ##error##. To see the SQL statements XWiki sends to the database, lower the logger the file already declares for them.(((
24 {{code language="xml"}}
25 <logger name="org.hibernate.SQL" level="debug"/>
26 {{/code}}
27 )))
28 1. Restart the servlet container. Logback reads the file once at start-up, so nothing changes until then.(((
29 {{code language="bash"}}
30 sudo systemctl restart tomcat11 # a Tomcat package
31 sudo systemctl restart xwiki # the Debian or Ubuntu Jetty package
32 ./stop_xwiki.sh && ./start_xwiki.sh # the standalone distribution
33 {{/code}}
34 )))
35 1. Exercise the feature you are investigating and read the log. The records you asked for are now there, at the level you set, and they stay there across every later restart.(((
36 {{code language="none"}}
37 2026-11-10 16:12:51,759 [qtp927327686-37 - http://localhost:8080/xwiki/bin/get/Sandbox/WebHome?] DEBUG o.h.SQL - select count(*) as col_0_0_ from xwikispace xwikispace0_ where xwikispace0_.XWS_PARENT=?
38 2026-11-10 16:12:51,830 [qtp927327686-166 - http://localhost:8080/xwiki/bin/get/Sandbox/WebHome?] DEBUG o.h.SQL - select count(*) as col_0_0_ from xwikispace xwikispace0_ where xwikispace0_.XWS_PARENT=? and xwikispace0_.XWS_HIDDEN<>true
39 {{/code}}
40 )))

Get Connected