public class LoggingApplicationListener extends Object implements org.springframework.context.event.SmartApplicationListener
ApplicationListener that configures a logging framework depending on what it
finds on the classpath and in the Environment. If the environment contains a
property logging.config then that will be used to initialize the logging
system, otherwise a default location is used. The classpath is probed for log4j and
logback and if those are present they will be reconfigured, otherwise vanilla
java.util.logging will be used.
The default config locations are classpath:log4j.properties or
classpath:log4j.xml for log4j; classpath:logback.xml for
logback; and classpath:logging.properties for
java.util.logging. If the correct one of those files is not found then
some sensible defaults are adopted from files of the same name but in the package
containing LoggingApplicationListener.
Some system properties may be set as side effects, and these can be useful if the logging configuration supports placeholders (i.e. log4j or logback):
LOG_FILE is set to the value of logging.file if found in
the environmentLOG_PATH is set to the value of logging.path if found in
the environmentPID is set to the value of the current process ID if it can be
determined| Constructor and Description |
|---|
LoggingApplicationListener() |
| Modifier and Type | Method and Description |
|---|---|
int |
getOrder() |
protected void |
initialize(org.springframework.core.env.ConfigurableEnvironment environment,
ClassLoader classLoader)
Initialize the logging system according to preferences expressed through the
Environment and the classpath. |
protected void |
initializeLogLevel(LoggingSystem system,
LogLevel level) |
void |
onApplicationEvent(org.springframework.context.ApplicationEvent event) |
void |
setOrder(int order) |
void |
setParseArgs(boolean parseArgs)
Sets if initialization arguments should be parsed for --debug and
--trace options.
|
void |
setSpringBootLogging(LogLevel springBootLogging)
Sets a custom logging level to be used for Spring Boot and related libraries.
|
boolean |
supportsEventType(Class<? extends org.springframework.context.ApplicationEvent> eventType) |
boolean |
supportsSourceType(Class<?> sourceType) |
public static final String PID_KEY
public boolean supportsEventType(Class<? extends org.springframework.context.ApplicationEvent> eventType)
supportsEventType in interface org.springframework.context.event.SmartApplicationListenerpublic boolean supportsSourceType(Class<?> sourceType)
supportsSourceType in interface org.springframework.context.event.SmartApplicationListenerpublic void onApplicationEvent(org.springframework.context.ApplicationEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>protected void initialize(org.springframework.core.env.ConfigurableEnvironment environment,
ClassLoader classLoader)
Environment and the classpath.protected void initializeLogLevel(LoggingSystem system, LogLevel level)
public void setOrder(int order)
public int getOrder()
getOrder in interface org.springframework.core.Orderedpublic void setSpringBootLogging(LogLevel springBootLogging)
springBootLogging - the logging levelpublic void setParseArgs(boolean parseArgs)
true.parseArgs - if arguments should be parsedCopyright © 2014 Pivotal Software, Inc.. All rights reserved.