org.springframework.boot.context.initializer
Class LoggingApplicationContextInitializer

java.lang.Object
  extended by org.springframework.boot.context.initializer.LoggingApplicationContextInitializer
All Implemented Interfaces:
SpringApplicationInitializer, org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>, org.springframework.core.Ordered

public class LoggingApplicationContextInitializer
extends Object
implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>, SpringApplicationInitializer, org.springframework.core.Ordered

An ApplicationContextInitializer that configures a logging framework depending on what it finds on the classpath and in the Environment. If the environment contains a property logging.config then that will be used to initialize the logging system, otherwise a default location is used. The classpath is probed for log4j and logback and if those are present they will be reconfigured, otherwise vanilla java.util.logging will be used.

The default config locations are classpath:log4j.properties or classpath:log4j.xml for log4j; classpath:logback.xml for logback; and classpath:logging.properties for java.util.logging. If the correct one of those files is not found then some sensible defaults are adopted from files of the same name but in the package containing LoggingApplicationContextInitializer.

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):

Author:
Dave Syer, Phillip Webb

Field Summary
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
LoggingApplicationContextInitializer()
           
 
Method Summary
 int getOrder()
           
 void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext)
          Initialize the logging system according to preferences expressed through the Environment and the classpath.
 void initialize(SpringApplication springApplication, String[] args)
          Initialize the application
protected  void initializeLogLevel(LoggingSystem system, LogLevel level)
           
 void setOrder(int order)
           
 void setParseArgs(boolean parseArgs)
          Sets if initialization arguments should be parsed for --debug and --trace options.
 void setSpringBootLogging(LogLevel springBootLogging)
          Sets a custom logging level to be used for Spring Boot and related libraries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingApplicationContextInitializer

public LoggingApplicationContextInitializer()
Method Detail

initialize

public void initialize(SpringApplication springApplication,
                       String[] args)
Description copied from interface: SpringApplicationInitializer
Initialize the application

Specified by:
initialize in interface SpringApplicationInitializer
Parameters:
springApplication - the spring application.
args - the run arguments

initialize

public void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext)
Initialize the logging system according to preferences expressed through the Environment and the classpath.

Specified by:
initialize in interface org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>

initializeLogLevel

protected void initializeLogLevel(LoggingSystem system,
                                  LogLevel level)

setOrder

public void setOrder(int order)

getOrder

public int getOrder()
Specified by:
getOrder in interface org.springframework.core.Ordered

setSpringBootLogging

public void setSpringBootLogging(LogLevel springBootLogging)
Sets a custom logging level to be used for Spring Boot and related libraries.

Parameters:
springBootLogging - the logging level

setParseArgs

public void setParseArgs(boolean parseArgs)
Sets if initialization arguments should be parsed for --debug and --trace options. Defaults to true.

Parameters:
parseArgs - if arguments should be parsed


Copyright © 2013. All Rights Reserved.