Skip to content

Commit

Permalink
The core.Logger#setLevel method should work like
Browse files Browse the repository at this point in the history
Configurator#setLevel #2281
  • Loading branch information
garydgregory committed Feb 13, 2024
1 parent e87064f commit cb1f19f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.spi.LoggerContext;

Expand Down Expand Up @@ -127,7 +128,7 @@ public static void setAdditivity(final Logger logger, final boolean additive) {
*/
public static void setLevel(final Logger logger, final Level level) {
if (isCore(logger)) {
asCore(logger).setLevel(level);
Configurator.setLevel(asCore(logger), level);
}
}

Expand Down
3 changes: 3 additions & 0 deletions log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.logging.log4j.core.test.appender.ListAppender;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -76,8 +77,10 @@ public static void tearDownClass() {
}

@After
@Before
public void tearDown() {
LoggerContext.getContext().reconfigure();
Logger.getRootLogger().setLevel(Level.DEBUG);
a1 = null;
a2 = null;
}
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<version>0.16.1</version>
<configuration>
<consoleOutput>true</consoleOutput>
<excludes combine.children="append">
Expand Down

0 comments on commit cb1f19f

Please sign in to comment.