Skip to content

Fix SLF4JLogger.atFatal() returning Level.TRACE instead of Level.FATAL - #4089

Merged
vy merged 4 commits into
apache:2.xfrom
cookiejack15:fix/slf4j-atFatal-wrong-level
Apr 12, 2026
Merged

vy merged 4 commits into
apache:2.xfrom
cookiejack15:fix/slf4j-atFatal-wrong-level

Conversation

@cookiejack15

Copy link
Copy Markdown
Contributor

Fixes #4068.

Summary

SLF4JLogger.atFatal() returns atLevel(Level.TRACE) instead of atLevel(Level.FATAL). This was a copy-paste error introduced in commit 113a8e85f4 (LOG4J2-3647, 2023-01-13). Every logger.atFatal().log(...) call through the log4j-to-slf4j bridge emits at TRACE level, causing the message to be silently discarded in any environment where TRACE is disabled.

Changes

  • SLF4JLogger.java: Changed Level.TRACE to Level.FATAL in atFatal()
  • Changelog: Added entry 4068_fix_SLF4JLogger_atFatal_wrong_level.xml

Affected versions

2.20.0 through 2.24.3 (every release since the fluent API was added to the SLF4J bridge).

…evel.FATAL (apache#4068)

atFatal() was copied from atTrace() in commit 113a8e8 (LOG4J2-3647)
and the level constant was never updated. This caused every
logger.atFatal().log(...) call through the log4j-to-slf4j bridge to
emit at TRACE level, silently discarding the message in any environment
where TRACE is disabled.

Fix: change Level.TRACE to Level.FATAL in SLF4JLogger.atFatal().
@ppkarwasz

Copy link
Copy Markdown
Member

High @cookiejack15,

Thank you for your PR. Could you add a unit test to prevent regressions?

Verifies that atFatal() produces a log event at ERROR level (SLF4J
equivalent of FATAL) instead of being silently discarded as TRACE.
@cookiejack15

Copy link
Copy Markdown
Contributor Author

Hello @ppkarwasz,

Thank you for the review.

i added a parameterized test in LogBuilderTest that verifies atFatal() produces a log event. Follows the same pattern as the existing testLevelThreshold test

@github-actions

github-actions Bot commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor
Job Requested goals Build Tool Version Build Outcome Build Scan®
build-macos-latest clean install 3.9.8 ✅ Build Scan PUBLISHED
build-ubuntu-latest clean install 3.9.8 ✅ Build Scan PUBLISHED
build-windows-latest clean install 3.9.8 ✅ Build Scan PUBLISHED
Generated by gradle/develocity-actions

Comment thread src/changelog/.2.x.x/4068_fix_SLF4JLogger_atFatal_wrong_level.xml
@vy
vy enabled auto-merge (squash) April 12, 2026 08:23
@vy
vy merged commit 83702bb into apache:2.x Apr 12, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Merged in Log4j pull request tracker Apr 12, 2026
ramanathan1504 pushed a commit to ramanathan1504/logging-log4j2 that referenced this pull request Apr 23, 2026
ramanathan1504 pushed a commit to ramanathan1504/logging-log4j2 that referenced this pull request Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

SLF4JLogger.atFatal() returns atLevel(Level.TRACE) instead of Level.FATAL — silent loss of FATAL log events

3 participants