Skip to content

Commit f5dbd85

Browse files
committed
Stop Log4j2 configuration to hopefully close the log file
See gh-47424
1 parent 2c56300 commit f5dbd85

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.apache.logging.log4j.core.LoggerContext;
3838
import org.apache.logging.log4j.core.config.Configuration;
3939
import org.apache.logging.log4j.core.config.LoggerConfig;
40-
import org.apache.logging.log4j.core.config.Reconfigurable;
4140
import org.apache.logging.log4j.core.config.composite.CompositeConfiguration;
4241
import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry;
4342
import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
@@ -114,16 +113,8 @@ void setup(TestInfo testInfo) {
114113

115114
@AfterEach
116115
void cleanUp() {
116+
this.loggingSystem.getConfiguration().stop();
117117
this.loggingSystem.cleanUp();
118-
LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
119-
Configuration configuration = loggerContext.getConfiguration();
120-
loggerContext.stop();
121-
if (configuration instanceof Reconfigurable reconfigurable) {
122-
loggerContext.start(reconfigurable.reconfigure());
123-
}
124-
else {
125-
loggerContext.start(configuration);
126-
}
127118
PluginRegistry.getInstance().clear();
128119
}
129120

0 commit comments

Comments
 (0)