|
|
|
@ -109,6 +109,31 @@ public class LoggingApplicationListener implements GenericApplicationListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String EXCEPTION_CONVERSION_WORD = "LOG_EXCEPTION_CONVERSION_WORD"; |
|
|
|
public static final String EXCEPTION_CONVERSION_WORD = "LOG_EXCEPTION_CONVERSION_WORD"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The name of the System property that contains the log file. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final String LOG_FILE = "LOG_FILE"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The name of the System property that contains the log file. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final String LOG_PATH = "LOG_PATH"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The name of the System property that contains the console log pattern |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final String CONSOLE_LOG_PATTERN = "CONSOLE_LOG_PATTERN"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The name of the System property that contains the file log pattern |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final String FILE_LOG_PATTERN = "FILE_LOG_PATTERN"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The name of the System property that contains the log level pattern |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final String LOG_LEVEL_PATTERN = "LOG_LEVEL_PATTERN"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The name of the {@link LoggingSystem} bean. |
|
|
|
* The name of the {@link LoggingSystem} bean. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -222,23 +247,38 @@ public class LoggingApplicationListener implements GenericApplicationListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void initialize(ConfigurableEnvironment environment, |
|
|
|
protected void initialize(ConfigurableEnvironment environment, |
|
|
|
ClassLoader classLoader) { |
|
|
|
ClassLoader classLoader) { |
|
|
|
if (System.getProperty(PID_KEY) == null) { |
|
|
|
LogFile logFile = LogFile.get(environment); |
|
|
|
System.setProperty(PID_KEY, new ApplicationPid().toString()); |
|
|
|
setSystemProperties(environment, logFile); |
|
|
|
} |
|
|
|
|
|
|
|
if (System.getProperty(EXCEPTION_CONVERSION_WORD) == null) { |
|
|
|
|
|
|
|
System.setProperty(EXCEPTION_CONVERSION_WORD, |
|
|
|
|
|
|
|
getExceptionConversionWord(environment)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
initializeEarlyLoggingLevel(environment); |
|
|
|
initializeEarlyLoggingLevel(environment); |
|
|
|
initializeSystem(environment, this.loggingSystem); |
|
|
|
initializeSystem(environment, this.loggingSystem, logFile); |
|
|
|
initializeFinalLoggingLevels(environment, this.loggingSystem); |
|
|
|
initializeFinalLoggingLevels(environment, this.loggingSystem); |
|
|
|
registerShutdownHookIfNecessary(environment, this.loggingSystem); |
|
|
|
registerShutdownHookIfNecessary(environment, this.loggingSystem); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String getExceptionConversionWord(ConfigurableEnvironment environment) { |
|
|
|
private void setSystemProperties(ConfigurableEnvironment environment, |
|
|
|
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, |
|
|
|
LogFile logFile) { |
|
|
|
"logging."); |
|
|
|
RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver( |
|
|
|
return resolver.getProperty("exception-conversion-word", "%wEx"); |
|
|
|
environment, "logging."); |
|
|
|
|
|
|
|
setSystemProperty(propertyResolver, EXCEPTION_CONVERSION_WORD, |
|
|
|
|
|
|
|
"exception-conversion-word"); |
|
|
|
|
|
|
|
setSystemProperty(propertyResolver, CONSOLE_LOG_PATTERN, "pattern.console"); |
|
|
|
|
|
|
|
setSystemProperty(propertyResolver, FILE_LOG_PATTERN, "pattern.file"); |
|
|
|
|
|
|
|
setSystemProperty(propertyResolver, LOG_LEVEL_PATTERN, "pattern.level"); |
|
|
|
|
|
|
|
setSystemProperty(PID_KEY, new ApplicationPid().toString()); |
|
|
|
|
|
|
|
if (logFile != null) { |
|
|
|
|
|
|
|
logFile.applyToSystemProperties(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setSystemProperty(RelaxedPropertyResolver propertyResolver, |
|
|
|
|
|
|
|
String systemPropertyName, String propertyName) { |
|
|
|
|
|
|
|
setSystemProperty(systemPropertyName, propertyResolver.getProperty(propertyName)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setSystemProperty(String name, String value) { |
|
|
|
|
|
|
|
if (System.getProperty(name) == null && value != null) { |
|
|
|
|
|
|
|
System.setProperty(name, value); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initializeEarlyLoggingLevel(ConfigurableEnvironment environment) { |
|
|
|
private void initializeEarlyLoggingLevel(ConfigurableEnvironment environment) { |
|
|
|
@ -253,10 +293,9 @@ public class LoggingApplicationListener implements GenericApplicationListener { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initializeSystem(ConfigurableEnvironment environment, |
|
|
|
private void initializeSystem(ConfigurableEnvironment environment, |
|
|
|
LoggingSystem system) { |
|
|
|
LoggingSystem system, LogFile logFile) { |
|
|
|
LoggingInitializationContext initializationContext = new LoggingInitializationContext( |
|
|
|
LoggingInitializationContext initializationContext = new LoggingInitializationContext( |
|
|
|
environment); |
|
|
|
environment); |
|
|
|
LogFile logFile = LogFile.get(environment); |
|
|
|
|
|
|
|
String logConfig = environment.getProperty(CONFIG_PROPERTY); |
|
|
|
String logConfig = environment.getProperty(CONFIG_PROPERTY); |
|
|
|
if (ignoreLogConfig(logConfig)) { |
|
|
|
if (ignoreLogConfig(logConfig)) { |
|
|
|
system.initialize(initializationContext, null, logFile); |
|
|
|
system.initialize(initializationContext, null, logFile); |
|
|
|
|