类 LoggingApplicationListener
- java.lang.Object
- org.springframework.boot.context.logging.LoggingApplicationListener
- 所有已实现的接口:
EventListener
,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
,org.springframework.context.event.GenericApplicationListener
,org.springframework.core.Ordered
public class LoggingApplicationListener extends Object implements org.springframework.context.event.GenericApplicationListener
AnApplicationListener
that configures theLoggingSystem
. If the environment contains alogging.config
property it will be used to bootstrap the logging system, otherwise a default configuration is used. Regardless, logging levels will be customized if the environment containslogging.level.*
entries and logging groups can be defined withlogging.group
.Debug and trace logging for Spring, Tomcat, Jetty and Hibernate will be enabled when the environment contains
debug
ortrace
properties that aren't set to"false"
(i.e. if you start your application using java -jar myapp.jar [--debug | --trace]). If you prefer to ignore these properties you can setparseArgs
tofalse
.By default, log output is only written to the console. If a log file is required the
logging.path
andlogging.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.
- 从以下版本开始:
- 2.0.0
- 另请参阅:
LoggingSystem.get(ClassLoader)
字段概要
字段 修饰符和类型 字段 说明 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
LOGGING_SYSTEM_BEAN_NAME
The name of theLoggingSystem
bean.static String
REGISTER_SHUTDOWN_HOOK_PROPERTY
The name of the Spring property that controls the registration of a shutdown hook to shut down the logging system when the JVM exits.
构造器概要
构造器 构造器 说明 LoggingApplicationListener()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 int
getOrder()
protected void
initialize(org.springframework.core.env.ConfigurableEnvironment environment, ClassLoader classLoader)
Initialize the logging system according to preferences expressed through theEnvironment
and the classpath.protected void
initializeLogLevel(LoggingSystem system, LogLevel level)
void
onApplicationEvent(org.springframework.context.ApplicationEvent event)
protected void
setLogLevels(LoggingSystem system, org.springframework.core.env.Environment environment)
void
setOrder(int order)
void
setParseArgs(boolean parseArgs)
Sets if initialization arguments should be parsed for debug and trace properties (usually defined from --debug or --trace command line args).void
setSpringBootLogging(LogLevel springBootLogging)
Sets a custom logging level to be used for Spring Boot and related libraries.boolean
supportsEventType(org.springframework.core.ResolvableType resolvableType)
boolean
supportsSourceType(Class<?> sourceType)
字段详细资料
DEFAULT_ORDER
public static final int DEFAULT_ORDER
The default order for the LoggingApplicationListener.- 另请参阅:
- 常量字段值
CONFIG_PROPERTY
public static final String CONFIG_PROPERTY
The name of the Spring property that contains a reference to the logging configuration to load.- 另请参阅:
- 常量字段值
REGISTER_SHUTDOWN_HOOK_PROPERTY
public static final String REGISTER_SHUTDOWN_HOOK_PROPERTY
The name of the Spring property that controls the registration of a shutdown hook to shut down the logging system when the JVM exits.
LOGGING_SYSTEM_BEAN_NAME
public static final String LOGGING_SYSTEM_BEAN_NAME
The name of theLoggingSystem
bean.- 另请参阅:
- 常量字段值
构造器详细资料
LoggingApplicationListener
public LoggingApplicationListener()
方法详细资料
supportsEventType
public boolean supportsEventType(org.springframework.core.ResolvableType resolvableType)
- 指定者:
supportsEventType
在接口中org.springframework.context.event.GenericApplicationListener
supportsSourceType
public boolean supportsSourceType(Class<?> sourceType)
- 指定者:
supportsSourceType
在接口中org.springframework.context.event.GenericApplicationListener
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
- 指定者:
onApplicationEvent
在接口中org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
initialize
protected void initialize(org.springframework.core.env.ConfigurableEnvironment environment, ClassLoader classLoader)
Initialize the logging system according to preferences expressed through theEnvironment
and the classpath.- 参数:
environment
- the environmentclassLoader
- the classloader
initializeLogLevel
protected void initializeLogLevel(LoggingSystem system, LogLevel level)
setLogLevels
protected void setLogLevels(LoggingSystem system, org.springframework.core.env.Environment environment)
setOrder
public void setOrder(int order)
getOrder
public int getOrder()
- 指定者:
getOrder
在接口中org.springframework.context.event.GenericApplicationListener
- 指定者:
getOrder
在接口中org.springframework.core.Ordered
setSpringBootLogging
public void setSpringBootLogging(LogLevel springBootLogging)
Sets a custom logging level to be used for Spring Boot and related libraries.- 参数:
springBootLogging
- the logging level
setParseArgs
public void setParseArgs(boolean parseArgs)
Sets if initialization arguments should be parsed for debug and trace properties (usually defined from --debug or --trace command line args). Defaults totrue
.- 参数:
parseArgs
- if arguments should be parsed