Continue with default location if CONFIG_LOGGING fails
Tomcat in particular sets an environment variable in it's shell scripts that people commonly use to start the container. So if people deploy a war file to a stock Tomcat server they can't override the logging config, even with the default location. With this change at least that should work (for logback and log4j anyway). Tested with logback. See gh-1432
This commit is contained in:
parent
47b59046bd
commit
c2444aecd6
|
@ -185,19 +185,20 @@ public class LoggingApplicationListener implements SmartApplicationListener {
|
|||
system.initialize(value);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.logger.warn("Logging environment value '" + value
|
||||
+ "' cannot be opened and will be ignored");
|
||||
this.logger
|
||||
.warn("Logging environment value '"
|
||||
+ value
|
||||
+ "' cannot be opened and will be ignored (using default location instead)");
|
||||
system.initialize();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
system.initialize();
|
||||
if (this.springBootLogging != null) {
|
||||
initializeLogLevel(system, this.springBootLogging);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.springBootLogging != null) {
|
||||
initializeLogLevel(system, this.springBootLogging);
|
||||
}
|
||||
setLogLevels(system, environment);
|
||||
|
||||
}
|
||||
|
|
|
@ -126,6 +126,11 @@ public class LoggingApplicationListenerTests {
|
|||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
this.context.getClassLoader());
|
||||
// Should not throw
|
||||
this.logger.info("Hello world");
|
||||
String output = this.outputCapture.toString().trim();
|
||||
assertTrue("Wrong output:\n" + output, output.contains("Hello world"));
|
||||
assertFalse("Wrong output:\n" + output, output.contains("???"));
|
||||
assertTrue(new File(tmpDir() + "/spring.log").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue