Wiki source code of Replace Logback with Another SLF4J Provider
Last modified by Eleni Cojocariu on 2026/11/24 18:38
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Run XWiki's logging on a backend other than Logback by swapping the SLF4J provider in ##WEB-INF/lib##, at the cost of the features [[XWiki builds on Logback>>doc:documentation.xs.admin.logging.WebHome]]. | ||
| 2 | |||
| 3 | 1. Remove the Logback provider from ##WEB-INF/lib##.((( | ||
| 4 | {{code language="none"}} | ||
| 5 | logback-classic-*.jar | ||
| 6 | logback-core-*.jar | ||
| 7 | {{/code}} | ||
| 8 | ))) | ||
| 9 | 1. Remove XWiki's own Logback integration, which has nowhere left to plug into. This is the step with a visible consequence: ##DefaultLoggerManager## is the only implementation XWiki has of the component the [[Logging Application>>doc:documentation.xs.admin.logging.change-levels-runtime.WebHome]] reads and writes levels through, and ##LogbackEventGenerator## is what turns log records into the events the per-job logs are built from. Without them, the administration screen has nothing to show and jobs such as an extension installation no longer keep a log of their own.((( | ||
| 10 | {{code language="none"}} | ||
| 11 | xwiki-commons-logging-logback-*.jar | ||
| 12 | {{/code}} | ||
| 13 | ))) | ||
| 14 | 1. Remove the SLF4J bridge for the framework you are moving **to**, or its records will be handed to SLF4J and then back to itself. Moving to Log4j 2 means removing both of the Log4j bridges.((( | ||
| 15 | {{code language="none"}} | ||
| 16 | log4j-over-slf4j-*.jar only if you move to Log4j 1.x | ||
| 17 | log4j-to-slf4j-*.jar only if you move to Log4j 2 | ||
| 18 | {{/code}} | ||
| 19 | ))) | ||
| 20 | 1. Add the backend and its SLF4J 2 provider. For Log4j 2 that is ##log4j-core## plus ##log4j-slf4j2-impl##; ##log4j-api## is already in ##WEB-INF/lib##, so check the version before adding a second copy. | ||
| 21 | 1. Write the backend's own configuration file into ##WEB-INF/classes##, since ##logback.xml## means nothing to it, and give it at least the levels the Logback configuration had. | ||
| 22 | 1. Restart the servlet container. XWiki's startup records now come out through the new backend, wherever its configuration sends them, and the line format is the one that configuration defines rather than Logback's.((( | ||
| 23 | {{code language="none"}} | ||
| 24 | 2026-11-10 16:12:37,160 [main] INFO o.x.e.i.ServletEnvironment - Using permanent directory [data] | ||
| 25 | {{/code}} | ||
| 26 | ))) |