This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/2.x by this push:
new 83702bb619 Fix SLF4JLogger.atFatal() returning Level.TRACE instead of
Level.FATAL (#4089)
83702bb619 is described below
commit 83702bb6194182572eccf6594acf935f83437e76
Author: yuno <[email protected]>
AuthorDate: Sun Apr 12 10:40:53 2026 +0200
Fix SLF4JLogger.atFatal() returning Level.TRACE instead of Level.FATAL
(#4089)
Co-authored-by: Piotr P. Karwasz <[email protected]>
Co-authored-by: Volkan Yazıcı <[email protected]>
---
.../main/java/org/apache/logging/slf4j/SLF4JLogger.java | 2 +-
.../java/org/apache/logging/slf4j/LogBuilderTest.java | 16 ++++++++++++++++
.../.2.x.x/4068_fix_SLF4JLogger_atFatal_wrong_level.xml | 13 +++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git
a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
index ff9410f33e..130d550d67 100644
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
+++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
@@ -363,7 +363,7 @@ public class SLF4JLogger extends AbstractLogger {
@Override
public LogBuilder atFatal() {
- return atLevel(Level.TRACE);
+ return atLevel(Level.FATAL);
}
@Override
diff --git
a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java
b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java
index cf80edc62a..ebebb31a00 100644
--- a/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java
+++ b/log4j-to-slf4j/src/test/java/org/apache/logging/slf4j/LogBuilderTest.java
@@ -103,4 +103,20 @@ class LogBuilderTest {
assertThat(list.strList).hasSize(1);
list.strList.clear();
}
+
+ /**
+ * Verifies that {@code atFatal()} delegates to {@code
atLevel(Level.FATAL)}
+ * and not {@code atLevel(Level.TRACE)}.
+ *
+ * @see <a
href="https://github.com/apache/logging-log4j2/issues/4068">#4068</a>
+ */
+ @ParameterizedTest
+ @MethodSource("logBuilderMethods")
+ void atFatal_should_log_at_error_level(final Consumer<LogBuilder>
consumer) {
+ consumer.accept(logger.atFatal());
+ assertThat(list.strList)
+ .as("atFatal() must produce a log event (SLF4J ERROR
equivalent)")
+ .hasSize(1);
+ list.strList.clear();
+ }
}
diff --git a/src/changelog/.2.x.x/4068_fix_SLF4JLogger_atFatal_wrong_level.xml
b/src/changelog/.2.x.x/4068_fix_SLF4JLogger_atFatal_wrong_level.xml
new file mode 100644
index 0000000000..811996eb8d
--- /dev/null
+++ b/src/changelog/.2.x.x/4068_fix_SLF4JLogger_atFatal_wrong_level.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <issue id="4068"
link="https://github.com/apache/logging-log4j2/issues/4068"/>
+ <issue id="4089"
link="https://github.com/apache/logging-log4j2/pull/4089"/>
+ <description format="asciidoc">
+ Fixed `SLF4JLogger.atFatal()` returning `atLevel(Level.TRACE)` instead
of `atLevel(Level.FATAL)`, which caused FATAL log events to be silently
discarded when using the fluent API through the `log4j-to-slf4j` bridge.
+ </description>
+</entry>