public class LogbackConfigurer extends LogbackConfigurerAdapter
The LogbackConfigurer can be used to configure logback based on one or more xml configuration resources. The configurer must be created as a Spring bean as the actual configuration will be done in the @PostConstruct of the bean.
Example usage in Spring @Configuration:
@Bean
public LogbackConfigurer logbackConfigurer( @Value("${log.dir}") String logDir,
@Value("${log.config}") Resource baseConfig,
@Value("${log.config.extend}") Resource envConfig ) {
return new LogbackConfigurer( logDir, baseConfig, envConfig );
}
Properties configuration:
# logging configuration log.dir=/logs/myapplication log.config=classpath:/config/logback.xml log.config.extend=classpath:/config/development/logback.xml
Note: number of resources passed in is variable, and resources do not have to exist as they will be ignored if they don't. In Spring xml configuration, resources should be passed in as a collection.
| Constructor and Description |
|---|
LogbackConfigurer(String logDir,
org.springframework.core.io.Resource... configurationResources)
Create a configurer with the specified log directory and one or more XML resources.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addConfigurationResources(Collection<org.springframework.core.io.Resource> resources)
Add XML configuration resources in this method.
|
protected void |
addProperties(Map<String,String> properties)
Add configuration properties to be passed to the XML resources in this method.
|
configure, configureLoggerContextpublic LogbackConfigurer(String logDir, org.springframework.core.io.Resource... configurationResources)
logDir - Base directory for log files - will be passed as ${log.dir} property.configurationResources - One or more XML (Joran style) resources.protected void addProperties(Map<String,String> properties)
LogbackConfigurerAdapteraddProperties in class LogbackConfigurerAdapterproperties - Map where properties should be added.protected void addConfigurationResources(Collection<org.springframework.core.io.Resource> resources)
LogbackConfigurerAdapteraddConfigurationResources in class LogbackConfigurerAdapterresources - Collection where XML resources should be added.Copyright © 2017. All rights reserved.