Update test to check file name and support URL sources

Closes gh-45398
This commit is contained in:
Phillip Webb
2025-05-08 11:59:36 -07:00
parent 9582ac7991
commit ba6539704e
2 changed files with 7 additions and 2 deletions

View File

@@ -159,7 +159,7 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
Configuration configuration = this.loggingSystem.getConfiguration();
assertThat(output).contains("Hello world").doesNotContain("Hidden");
assertThat(new File(tmpDir() + "/spring.log")).exists();
assertThat(configuration.getConfigurationSource().getFile()).isNotNull();
assertThat(configuration.getConfigurationSource().getLocation()).contains("/log4j2-file.xml");
}
@Test

View File

@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
class TestLog4J2LoggingSystem extends Log4J2LoggingSystem {
@@ -34,7 +35,11 @@ class TestLog4J2LoggingSystem extends Log4J2LoggingSystem {
}
Configuration getConfiguration() {
return ((org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false)).getConfiguration();
return getLoggerContext().getConfiguration();
}
private LoggerContext getLoggerContext() {
return (LoggerContext) LogManager.getContext(false);
}
@Override