dotCMS / dotCMS/core

Reduce log verbosity: collapse framework stack frames via log4j2 %xEx filters

Open
#36,515 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team : Platform Type : Task
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Description

Production logs (console and dotcms.log) are dominated by extremely long stack traces where the vast majority of frames are framework plumbing rather than dotCMS code. A single content-data error (e.g. a JSONException from StoryBlockFieldDataFetcher, or a DotDataException during starter import) produces 150+ log lines, of which only ~10 are dotCMS frames. The noise comes from:

  • Tomcat/Catalina lifecycle and filter-chain frames (org.apache.catalina, org.apache.coyote, org.apache.tomcat, javax.servlet)
  • GraphQL execution engine recursion (graphql.execution, graphql.kickstart)
  • Async plumbing (java.util.concurrent.CompletableFuture chains, sun.nio.ch)
  • Reflection internals (jdk.internal.reflect, java.lang.reflect)
  • URL rewrite and functional wrappers (org.tuckey, io.vavr)

This makes production logs hard to scan and inflates log storage/shipping volume.

Log4j2 has built-in support for this: the %xEx{filters(package, ...)} pattern converter collapses frames from listed packages into a single ... suppressed NN lines marker while keeping exception messages, Caused by chains, and all remaining frames intact.

Note: testing on log4j2 2.23.1 confirmed that %ex{filters(...)} is silently ignored — only %xEx{filters(...)} activates frame suppression. The existing test configs (dotcms-integration, dotcms-postman, e2e, config/user/logging) use %ex{filters(...)}, so their stack filtering has never actually worked.

Acceptance Criteria
  • Console and rolling-file pattern layouts in the runtime log4j2 configs (dotCMS/src/main/webapp/WEB-INF/log4j/log4j2.xml and the Docker override dotCMS/src/main/docker/original/ROOT/srv/OVERRIDE/WEB-INF/log4j/log4j2.xml) apply %xEx{filters(...)} with a shared stack.filter property listing framework packages.
  • Frames from filtered packages render as ... suppressed NN lines; all com.dotcms / com.dotmarketing frames, exception messages, and full Caused by chains remain visible.
  • A representative 150-line GraphQL trace and a 54-line Tomcat-startup trace render at roughly 10–15 lines.
  • Verified against log4j2 2.23.1 (the version pinned in bom/logging/pom.xml).
Priority

Medium

Additional Context

Example of the filtered output for the starter-import error (previously 54 lines):

ERROR util.RulesImportExportUtil: Error: Parent Identifier: f7ba5d94... does NOT exist.
com.dotmarketing.exception.DotDataException: Parent Identifier: ... does NOT exist.
    at com.dotmarketing.portlets.rules.util.RulePermissionableUtil.findParentPermissionable(...)
    at com.dotmarketing.portlets.rules.util.RulesImportExportUtil.importRules(...)
    at com.dotmarketing.util.starter.ImportStarterUtil.doImport(...)
    at com.dotmarketing.db.DotCMSInitDb.loadStarterSiteData(...)
    ... suppressed 1 lines
    at com.dotmarketing.startup.StartupTasksExecutor.executeStartUpTasks(...)
    at com.liferay.portal.servlet.MainServlet.init(...)
    ... suppressed 42 lines

Filtered packages: org.apache.catalina, org.apache.coyote, org.apache.tomcat, javax.servlet, org.tuckey, io.vavr, graphql.execution, graphql.kickstart, graphql.GraphQL, java.util.concurrent, java.lang.Thread, sun.nio.ch, jdk.internal.reflect, java.lang.reflect.

Follow-up candidate (out of scope): fix the broken %ex{filters(...)} usage in the test configs by switching them to %xEx.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the console and rolling-file layouts in dotCMS/src/main/webapp/WEB-INF/log4j/log4j2.xml and the Docker override at dotCMS/src/main/docker/original/ROOT/srv/OVERRIDE/WEB-INF/log4j/log4j2.xml. Check the pinned log4j2 version in bom/logging/pom.xml and validate the representative GraphQL and Tomcat traces. Done means filtered frames collapse while dotCMS frames, messages, and full Caused by chains remain visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.