LoggingApplicationListener

An ApplicationListener that configures the LoggingSystem. If the environment contains a logging.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 contains logging.level.* entries and logging groups can be defined with logging.group.

Debug and trace logging for Spring, Tomcat, Jetty and Hibernate will be enabled when the environment contains debug or trace 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 set parseArgs to false.

By default, log output is only written to the console. If a log file is required, the logging.file.path and logging.file.name 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.

Author

Dave Syer

Phillip Webb

Andy Wilkinson

Madhura Bhave

HaiTao Zhang

Since

2.0.0

See also

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val CONFIG_PROPERTY: String = "logging.config"
The name of the Spring property that contains a reference to the logging configuration to load.
Link copied to clipboard
val DEFAULT_ORDER: Int = -2147483628
The default order for the LoggingApplicationListener.
Link copied to clipboard
val HIGHEST_PRECEDENCE: Int = -2147483648
Link copied to clipboard
val LOG_FILE_BEAN_NAME: String = "springBootLogFile"
The name of the LogFile bean.
Link copied to clipboard
val LOGGER_GROUPS_BEAN_NAME: String = "springBootLoggerGroups"
The name of the LoggerGroups bean.
Link copied to clipboard
val LOGGING_SYSTEM_BEAN_NAME: String = "springBootLoggingSystem"
The name of the LoggingSystem bean.
Link copied to clipboard
val LOWEST_PRECEDENCE: Int = 2147483647
Link copied to clipboard
open var order: Int
Link copied to clipboard
val REGISTER_SHUTDOWN_HOOK_PROPERTY: String = "logging.register-shutdown-hook"
The name of the Spring property that controls the registration of a shutdown hook to shut down the logging system when the JVM exits.

Functions

Link copied to clipboard
open fun <E : ApplicationEvent?> forEventType(eventType: Class<E>, consumer: Consumer<E>): GenericApplicationListener
Link copied to clipboard
Link copied to clipboard
open fun getListenerId(): String
Link copied to clipboard
open fun getOrder(): Int
Link copied to clipboard
Link copied to clipboard
open fun setParseArgs(parseArgs: Boolean)
Sets if initialization arguments should be parsed for debug and trace properties (usually defined from --debug or --trace command line args).
Link copied to clipboard
open fun setSpringBootLogging(springBootLogging: LogLevel)
Sets a custom logging level to be used for Spring Boot and related libraries.
Link copied to clipboard
Link copied to clipboard
open fun supportsEventType(resolvableType: ResolvableType): Boolean
open fun supportsEventType(eventType: Class<out ApplicationEvent>): Boolean
Link copied to clipboard
open fun supportsSourceType(sourceType: Class<out Any>): Boolean