Set PID early for logging

Set PID early in the initialization process to ensure log enties are
not written without an ID.
This commit is contained in:
Phillip Webb 2013-07-17 23:25:24 -07:00
parent 1bec676ca1
commit 50109d4ace
2 changed files with 5 additions and 4 deletions

View File

@ -82,6 +82,9 @@ public class LoggingApplicationContextInitializer implements
@Override
public void initialize(SpringApplication springApplication) {
if (System.getProperty("PID") == null) {
System.setProperty("PID", getPid());
}
LoggingSystem.get(springApplication.getClass().getClassLoader())
.beforeInitialize();
}
@ -103,10 +106,6 @@ public class LoggingApplicationContextInitializer implements
}
}
if (System.getProperty("PID") == null) {
System.setProperty("PID", getPid());
}
LoggingSystem system = LoggingSystem.get(applicationContext.getClassLoader());
// User specified configuration

View File

@ -29,6 +29,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.bootstrap.SpringApplication;
import org.springframework.bootstrap.logging.java.JavaLoggingSystem;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.PropertySource;
@ -61,6 +62,7 @@ public class LoggingApplicationContextInitializerTests {
System.setOut(new PrintStream(this.output));
LogManager.getLogManager().readConfiguration(
JavaLoggingSystem.class.getResourceAsStream("logging.properties"));
this.initializer.initialize(new SpringApplication());
}
@After