Class LogbackInitializer
- java.lang.Object
-
- au.net.causal.shoelaces.logconfig.LogbackInitializer
-
- All Implemented Interfaces:
java.util.EventListener,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
@Order(-2147483638) public class LogbackInitializer extends java.lang.Object implements org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>Configures Logback logging if a logback configuration file exists in the application home directory.This initializer is called early when the Spring application is initialized. If the
logging.configproperty 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 thelogging.configproperty 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.factoriesso it is loaded at startup. If you wish to subclass and override some of this logic, you will need to also register your subclass usingspring.factoriesand ensure that your initializer has an order (using the@Orderannotation) that makes it run before this one.
-
-
Constructor Summary
Constructors Constructor Description LogbackInitializer()Default constructor, called by Spring.LogbackInitializer(java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.nio.file.PathgetAdditionalLogbackConfigurationFile(au.net.causal.shoelaces.apphome.ApplicationHome applicationHome)Finds the logback configuration file under the application home directory.voidonApplicationEvent(org.springframework.context.ApplicationEvent event)
-
-
-
Constructor Detail
-
LogbackInitializer
public LogbackInitializer()
Default constructor, called by Spring.
-
LogbackInitializer
public LogbackInitializer(java.lang.String logbackConfigFileName)
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 Detail
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
-
getAdditionalLogbackConfigurationFile
protected java.nio.file.Path getAdditionalLogbackConfigurationFile(au.net.causal.shoelaces.apphome.ApplicationHome applicationHome)
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.
-
-