Configure Log Levels

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

Steps

Change which messages XWiki writes to its log by editing the Logback configuration file, the only place where a level survives a restart.

  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.
    /var/lib/tomcat11/webapps/xwiki/WEB-INF/classes/logback.xml   a .war deployment on Tomcat
    webapps/xwiki/WEB-INF/classes/logback.xml                     the standalone distribution
    /etc/xwiki/logback.xml                                        a Debian or Ubuntu package
  2. 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.
    <root level="warn">
      <appender-ref ref="stdout"/>
    </root>
    
    <logger name="org.xwiki" level="info"/>
    <logger name="com.xwiki" level="info"/>
    <logger name="com.xpn.xwiki" level="warn"/>
    <logger name="org.hibernate" level="warn"/>
    <logger name="org.hibernate.SQL" level="warn"/>
  3. Set the level you want on the logger you want, naming it as precisely as the package tree allows. 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.
    <logger name="org.hibernate.SQL" level="debug"/>
  4. Restart the servlet container. Logback reads the file once at start-up, so nothing changes until then.
    sudo systemctl restart tomcat11    # a Tomcat package
    sudo systemctl restart xwiki       # the Debian or Ubuntu Jetty package
    ./stop_xwiki.sh && ./start_xwiki.sh   # the standalone distribution
  5. 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.
    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=?
    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

FAQ

Which logger name should I use?

The one the records already carry. The logger is the fourth field of each line, with its package shortened to initials, so o.h.SQL in the output above is org.hibernate.SQL. Change Log Levels at Runtime lists every registered logger under its full name.

Can I write the log to a file of my own?

Yes. Declare a Logback file appender in the same file and reference it from the root logger. The Docker image ships exactly that, with a rotation policy you can copy.

Related

Get Connected