Commit c2444aec authored by Dave Syer's avatar Dave Syer

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
parent 47b59046
...@@ -185,19 +185,20 @@ public class LoggingApplicationListener implements SmartApplicationListener { ...@@ -185,19 +185,20 @@ public class LoggingApplicationListener implements SmartApplicationListener {
system.initialize(value); system.initialize(value);
} }
catch (Exception ex) { catch (Exception ex) {
this.logger.warn("Logging environment value '" + value this.logger
+ "' cannot be opened and will be ignored"); .warn("Logging environment value '"
+ value
+ "' cannot be opened and will be ignored (using default location instead)");
system.initialize();
} }
} }
else { else {
system.initialize(); system.initialize();
if (this.springBootLogging != null) {
initializeLogLevel(system, this.springBootLogging);
}
} }
if (this.springBootLogging != null) {
initializeLogLevel(system, this.springBootLogging);
}
setLogLevels(system, environment); setLogLevels(system, environment);
} }
......
...@@ -126,6 +126,11 @@ public class LoggingApplicationListenerTests { ...@@ -126,6 +126,11 @@ public class LoggingApplicationListenerTests {
this.initializer.initialize(this.context.getEnvironment(), this.initializer.initialize(this.context.getEnvironment(),
this.context.getClassLoader()); this.context.getClassLoader());
// Should not throw // 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 @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment