commit
c3558689c7
|
@ -275,7 +275,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
|
|||
|
||||
private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext,
|
||||
URL url) throws JoranException {
|
||||
if (url.toString().endsWith(".xml")) {
|
||||
if (url.getPath().endsWith(".xml")) {
|
||||
JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
|
||||
configurator.setContext(loggerContext);
|
||||
configurator.doConfigure(url);
|
||||
|
|
|
@ -782,6 +782,25 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
|||
.hasAtLeastOneElementOfType(DynamicClassLoadingException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenConfigLocationIsNotXmlThenIllegalArgumentExceptionShouldBeThrown() {
|
||||
this.loggingSystem.beforeInitialize();
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> initialize(this.initializationContext, "classpath:logback-invalid-format.txt",
|
||||
getLogFile(tmpDir() + "/tmp.log", null)))
|
||||
.satisfies((ex) -> assertThat(ex.getCause()).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessageStartingWith("Unsupported file extension"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenConfigLocationIsXmlAndHasQueryParametersThenIllegalArgumentExceptionShouldNotBeThrown() {
|
||||
this.loggingSystem.beforeInitialize();
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> initialize(this.initializationContext, "file:///logback-nonexistent.xml?raw=true",
|
||||
getLogFile(tmpDir() + "/tmp.log", null)))
|
||||
.satisfies((ex) -> assertThat(ex.getCause()).isNotInstanceOf(IllegalArgumentException.class));
|
||||
}
|
||||
|
||||
private void initialize(LoggingInitializationContext context, String configLocation, LogFile logFile) {
|
||||
this.loggingSystem.getSystemProperties((ConfigurableEnvironment) context.getEnvironment()).apply(logFile);
|
||||
this.loggingSystem.beforeInitialize();
|
||||
|
|
Loading…
Reference in New Issue