fix(logging): route Tomcat JULI/catalina logs to console + dotcms.log in container (#36075)#36076
fix(logging): route Tomcat JULI/catalina logs to console + dotcms.log in container (#36075)#36076wezell wants to merge 2 commits into
Conversation
… in container (#36075) In the container, only dotCMS application logs (log4j2) reached the container log stream; Tomcat's internal java.util.logging (JULI / catalina) logs went to a separate catalina.<date>.log and did not surface. Bridge raw java.util.logging into log4j2 via log4j-jul's Log4jBridgeHandler so everything except access logs is unified to console (stdout) + dotcms.log: - bom/logging/pom.xml: add managed log4j-jul dependency. - dotCMS/pom.xml: declare log4j-jul (provided) and copy its jar into the Tomcat log4j2/lib folder (already on the JVM classpath via setenv.sh). - OVERRIDE tomcat/conf/logging.properties: replace the AsyncFileHandler (catalina.<date>.log) and ConsoleHandler with Log4jBridgeHandler. Access logs (AccessLogValve) bypass JULI and remain a separate file by design. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @wezell's task in 1m 55s —— View job PR Review
Clean. Two things worth a second look: 1.
Not a correctness bug — the library handles the race gracefully — but if someone ever reports noisy startup logs for a brief window, this is where to look. 2. BOM scope inconsistency In Worth aligning Not a concern (confirming the PR's claim): Double-logging between |
The jar lives on Tomcat's classpath, not the webapp classpath, so provided is the correct scope. Using runtime caused double-loading in modules that inherit the BOM without overriding the scope themselves. https://claude.ai/code/session_0137tNu61fbsugvh9KxeQLkB
Proposed Changes
Fixes #36075
In the container, only dotCMS application logs (log4j2) reached the container log stream. Tomcat's internal
java.util.logging(JULI / "catalina") logs —org.apache.catalina.*,org.apache.coyote.*— went to a separatecatalina.<date>.logand did not surface indocker logs/kubectl logs.This PR bridges raw
java.util.logginginto log4j2 vialog4j-jul'sLog4jBridgeHandler, so everything except access logs is unified to console (stdout) +dotcms.log.What changed
bom/logging/pom.xml— add managedlog4j-juldependency (${log4j.version}= 2.23.1).dotCMS/pom.xml— declarelog4j-jul(provided) and copy its jar into the Tomcatlog4j2/libfolder (already on the JVM classpath viasetenv.sh).OVERRIDE/.../tomcat/conf/logging.properties— replace the JULIAsyncFileHandler(catalina.<date>.log) +ConsoleHandlerwithorg.apache.logging.log4j.jul.Log4jBridgeHandler.Why this approach
log4j-appserver'sTomcatLogger(already bundled) only routes theorg.apache.juli.logging.Logfacade. Code logging directly viajava.util.loggingwas unbridged — this adds that bridge.Log4jBridgeHandleris the least-invasive option: it keeps Tomcat'sClassLoaderLogManagerand avoids any-Djava.util.logging.managerJVM-arg ordering risk vscatalina.sh.BasicAsyncLoggerContextSelector, set insetenv.sh) means anything reaching log4j2 lands in the existingConsole(stdout) +dotcms.logappenders.Access logs unchanged
Tomcat's
AccessLogValvewrites its own file and bypasses both JULI and the juli facade, so access logs remain a separate file by design.Testing / Verification
Built the arm64 image and ran it against Postgres; observed all four acceptance criteria:
dotcms.log(81 Tomcat-internal lines).catalina.<date>.logfile produced.dotcms_access.<date>.log).🤖 Generated with Claude Code