Class LogbackInitializer
- All Implemented Interfaces:
EventListener,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
This initializer is called early when the Spring application is initialized. If the logging.config
property isn't set (which would indicate the user wishes to use a custom logging configuration file), the
application home directory (see the application home Shoelaces module documentation for more info on this)
is searched for a logback configuration file, and if it exists then the logging.config
property is set to the location of this file. This allows users of a Spring Boot application that uses this
module to easily configure logging by adding a logging configuration file in a known place.
This initializer is registered with Spring using spring.factories so it is loaded at startup.
If you wish to subclass and override some of this logic, you will need to also register your subclass using
spring.factories and ensure that your initializer has an order
(using the @Order annotation) that makes it run before this one.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, called by Spring.LogbackInitializer(String logbackConfigFileName) Creates a logback intiializer that looks for a logback configuration file with the specified file name inside the application home directory. -
Method Summary
Modifier and TypeMethodDescriptionprotected PathgetAdditionalLogbackConfigurationFile(ApplicationHome applicationHome) Finds the logback configuration file under the application home directory.voidonApplicationEvent(org.springframework.context.ApplicationEvent event)
-
Constructor Details
-
LogbackInitializer
public LogbackInitializer()Default constructor, called by Spring. -
LogbackInitializer
Creates a logback intiializer that looks for a logback configuration file with the specified file name inside the application home directory.- Parameters:
logbackConfigFileName- logback configuration file name to look for under application home.
-
-
Method Details
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event) - Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
-
getAdditionalLogbackConfigurationFile
Finds the logback configuration file under the application home directory.- Parameters:
applicationHome- the application home.- Returns:
- the logback configuration file, or null if it does not exist.
-