This is an automated email from the ASF dual-hosted git repository.
ramanathan1504 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 c64ef11a41 Add missing RootLogger.Builder withFilter alias (#4224)
c64ef11a41 is described below
commit c64ef11a413e8813b320a0ae56277fe3b478199c
Author: Hashim Khan <[email protected]>
AuthorDate: Thu Aug 27 20:03:22 2026 +0500
Add missing RootLogger.Builder withFilter alias (#4224)
* Add missing RootLogger.Builder withFilter alias
---------
Co-authored-by: Ramanathan <[email protected]>
---
.../logging/log4j/core/config/LoggerConfigTest.java | 16 ++++++++++++++++
.../apache/logging/log4j/core/config/LoggerConfig.java | 8 ++++++++
.../apache/logging/log4j/core/config/package-info.java | 2 +-
.../3369_add_missing_RootLogger_withFilter_alias.xml | 13 +++++++++++++
4 files changed, 38 insertions(+), 1 deletion(-)
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java
index b25ef14a48..d57b1cf64f 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java
@@ -159,4 +159,20 @@ class LoggerConfigTest {
assertNotNull(loggerConfig.getAppenderRefs());
assertTrue(loggerConfig.getAppenderRefs().isEmpty());
}
+
+ @Test
+ @SuppressWarnings("deprecation")
+ void testRootLoggerBuilderWithFilterAlias() {
+ final Filter filter = mock(Filter.class);
+ final LoggerConfig viaTypo = LoggerConfig.RootLogger.newRootBuilder()
+ .setConfig(new NullConfiguration())
+ .withtFilter(filter)
+ .build();
+ final LoggerConfig viaAlias = LoggerConfig.RootLogger.newRootBuilder()
+ .setConfig(new NullConfiguration())
+ .withFilter(filter)
+ .build();
+ assertSame(filter, viaTypo.getFilter());
+ assertSame(filter, viaAlias.getFilter());
+ }
}
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
index 12b0b2f0ab..db5d599596 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
@@ -1136,6 +1136,14 @@ public class LoggerConfig extends AbstractFilterable
implements LocationAware {
return setFilter(filter);
}
+ /**
+ * @deprecated since 2.25.0. Use {@link #setFilter(Filter)}
instead.
+ */
+ @Deprecated
+ public B withFilter(final Filter filter) {
+ return setFilter(filter);
+ }
+
@Override
public LoggerConfig build() {
final LevelAndRefs container =
LoggerConfig.getLevelAndRefs(level, refs, levelAndRefs, config);
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/package-info.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/package-info.java
index b0dbdc1ea0..a37179d532 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/package-info.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/package-info.java
@@ -18,7 +18,7 @@
* Configuration of Log4j 2.
*/
@Export
-@Version("2.26.0")
+@Version("2.27.0")
package org.apache.logging.log4j.core.config;
import org.osgi.annotation.bundle.Export;
diff --git
a/src/changelog/.2.x.x/3369_add_missing_RootLogger_withFilter_alias.xml
b/src/changelog/.2.x.x/3369_add_missing_RootLogger_withFilter_alias.xml
new file mode 100644
index 0000000000..020d8e9830
--- /dev/null
+++ b/src/changelog/.2.x.x/3369_add_missing_RootLogger_withFilter_alias.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="added">
+ <issue id="3369"
link="https://github.com/apache/logging-log4j2/issues/3369"/>
+ <issue id="4224"
link="https://github.com/apache/logging-log4j2/pull/4224"/>
+ <description format="asciidoc">
+ Add missing `withFilter()` method to `LoggerConfig.RootLogger.Builder`
to fix `withtFilter` typo.
+ </description>
+</entry>
\ No newline at end of file