public class LoggingApplicationListener extends Object implements GenericApplicationListener
ApplicationListener
that configures the LoggingSystem
. If the
environment contains a logging.config
property a then that will be used to
initialize the logging system, otherwise a default configuration is used.
By default, log output is only written to the console. If a log file is required the
logging.path
and logging.file
properties can be used.
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 path of the log file that should be written
(if any).PID
is set to the value of the current process ID if it can be determined.LoggingSystem.get(ClassLoader)
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_PROPERTY
The name of the Spring property that contains a reference to the logging
configuration to load.
|
static int |
DEFAULT_ORDER
The default order for the LoggingApplicationListener.
|
static String |
EXCEPTION_CONVERSION_WORD
The name of the System property that contains the exception conversion word.
|
static String |
FILE_PROPERTY
The name of the Spring property that contains the name of the logging configuration
file.
|
static String |
PATH_PROPERTY
The name of the Spring property that contains the path where the logging
configuration can be found.
|
static String |
PID_KEY
The name of the System property that contains the process ID.
|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
LoggingApplicationListener() |
Modifier and Type | Method and Description |
---|---|
int |
getOrder() |
protected void |
initialize(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(ApplicationEvent event) |
protected void |
setLogLevels(LoggingSystem system,
Environment environment) |
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(ResolvableType resolvableType) |
boolean |
supportsSourceType(Class<?> sourceType) |
public static final int DEFAULT_ORDER
public static final String CONFIG_PROPERTY
public static final String PATH_PROPERTY
public static final String FILE_PROPERTY
public static final String PID_KEY
public static final String EXCEPTION_CONVERSION_WORD
public boolean supportsEventType(ResolvableType resolvableType)
supportsEventType
in interface GenericApplicationListener
public boolean supportsSourceType(Class<?> sourceType)
supportsSourceType
in interface GenericApplicationListener
public void onApplicationEvent(ApplicationEvent event)
onApplicationEvent
in interface ApplicationListener<ApplicationEvent>
protected void initialize(ConfigurableEnvironment environment, ClassLoader classLoader)
Environment
and the classpath.environment
- the environmentclassLoader
- the classloaderprotected void initializeLogLevel(LoggingSystem system, LogLevel level)
protected void setLogLevels(LoggingSystem system, Environment environment)
public void setOrder(int order)
public void setSpringBootLogging(LogLevel springBootLogging)
springBootLogging
- the logging levelpublic void setParseArgs(boolean parseArgs)
true
.parseArgs
- if arguments should be parsedCopyright © 2015 Pivotal Software, Inc.. All rights reserved.