View Javadoc
1   package org.kuali.common.util.log4j.spring;
2   
3   import java.util.Arrays;
4   
5   import org.apache.log4j.ConsoleAppender;
6   import org.apache.log4j.PatternLayout;
7   import org.kuali.common.util.xml.service.XmlService;
8   import org.kuali.common.util.xml.spring.XmlServiceConfig;
9   import org.springframework.beans.factory.annotation.Autowired;
10  import org.springframework.context.annotation.Bean;
11  import org.springframework.context.annotation.Configuration;
12  import org.springframework.context.annotation.Import;
13  
14  /**
15   * @deprecated
16   */
17  @Deprecated
18  @Configuration
19  @Import({ XmlServiceConfig.class })
20  public class Log4JConfig {
21  
22  	protected static final String SPRING = "org.springframework";
23  	protected static final String STDOUT = "stdout";
24  
25  	@Autowired
26  	XmlServiceConfig xmlServiceConfig;
27  
28  	@Bean
29  	public org.kuali.common.util.log4j.Log4JService log4jService() {
30  		XmlService service = xmlServiceConfig.xmlService();
31  		return new org.kuali.common.util.log4j.DefaultLog4JService(service);
32  	}
33  
34  	@Bean
35  	public org.kuali.common.util.log4j.model.Log4JContext log4JContextDefault() {
36  		return getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.DEFAULT, org.kuali.common.util.log4j.model.Value.INFO);
37  	}
38  
39  	@Bean
40  	public org.kuali.common.util.log4j.model.Log4JContext log4JContextTest() {
41  		return getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.DEBUG, org.kuali.common.util.log4j.model.Value.INFO);
42  	}
43  
44  	@Bean
45  	public org.kuali.common.util.log4j.model.Log4JContext log4JContextDebug() {
46  		return getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.DEBUG, org.kuali.common.util.log4j.model.Value.DEBUG);
47  	}
48  
49  	@Bean
50  	public org.kuali.common.util.log4j.model.Log4JContext log4JContextMaven() {
51  		org.kuali.common.util.log4j.model.Log4JContext context = getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.MAVEN,org.kuali.common.util.log4j.model.Value.INFO);
52  		// Tone down Spring logging when we are running a build
53  		org.kuali.common.util.log4j.model.Logger spring = new org.kuali.common.util.log4j.model.Logger(SPRING, new org.kuali.common.util.log4j.model.Level(org.kuali.common.util.log4j.model.Value.WARN));
54  		context.setLoggers(Arrays.asList(spring));
55  		return context;
56  	}
57  
58  	protected org.kuali.common.util.log4j.model.Log4JContext getLog4JContext(String pattern, org.kuali.common.util.log4j.model.Value value) {
59  		org.kuali.common.util.log4j.model.Param param = new org.kuali.common.util.log4j.model.param.ConversionPatternParam(pattern);
60  		org.kuali.common.util.log4j.model.Layout layout = new org.kuali.common.util.log4j.model.Layout(PatternLayout.class, param);
61  		org.kuali.common.util.log4j.model.Appender console = new org.kuali.common.util.log4j.model.Appender(STDOUT, ConsoleAppender.class, layout);
62  		org.kuali.common.util.log4j.model.AppenderRef ref = new org.kuali.common.util.log4j.model.AppenderRef(console.getName());
63  		org.kuali.common.util.log4j.model.Logger root = new org.kuali.common.util.log4j.model.Logger(ref, new org.kuali.common.util.log4j.model.Level(value));
64  		return new org.kuali.common.util.log4j.model.Log4JContext(console, root, true);
65  	}
66  }