1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.log4j.spring;
17
18 import java.util.Arrays;
19
20 import org.apache.log4j.ConsoleAppender;
21 import org.apache.log4j.PatternLayout;
22 import org.kuali.common.util.xml.service.XmlService;
23 import org.kuali.common.util.xml.spring.XmlServiceConfig;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.context.annotation.Bean;
26 import org.springframework.context.annotation.Configuration;
27 import org.springframework.context.annotation.Import;
28
29
30
31
32 @Deprecated
33 @Configuration
34 @Import({ XmlServiceConfig.class })
35 public class Log4JConfig {
36
37 protected static final String SPRING = "org.springframework";
38 protected static final String STDOUT = "stdout";
39
40 @Autowired
41 XmlServiceConfig xmlServiceConfig;
42
43 @Bean
44 public org.kuali.common.util.log4j.Log4JService log4jService() {
45 XmlService service = xmlServiceConfig.xmlService();
46 return new org.kuali.common.util.log4j.DefaultLog4JService(service);
47 }
48
49 @Bean
50 public org.kuali.common.util.log4j.model.Log4JContext log4JContextDefault() {
51 return getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.DEFAULT, org.kuali.common.util.log4j.model.Value.INFO);
52 }
53
54 @Bean
55 public org.kuali.common.util.log4j.model.Log4JContext log4JContextTest() {
56 return getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.DEBUG, org.kuali.common.util.log4j.model.Value.INFO);
57 }
58
59 @Bean
60 public org.kuali.common.util.log4j.model.Log4JContext log4JContextDebug() {
61 return getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.DEBUG, org.kuali.common.util.log4j.model.Value.DEBUG);
62 }
63
64 @Bean
65 public org.kuali.common.util.log4j.model.Log4JContext log4JContextMaven() {
66 org.kuali.common.util.log4j.model.Log4JContext context = getLog4JContext(org.kuali.common.util.log4j.Log4JPatternConstants.MAVEN,org.kuali.common.util.log4j.model.Value.INFO);
67
68 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));
69 context.setLoggers(Arrays.asList(spring));
70 return context;
71 }
72
73 protected org.kuali.common.util.log4j.model.Log4JContext getLog4JContext(String pattern, org.kuali.common.util.log4j.model.Value value) {
74 org.kuali.common.util.log4j.model.Param param = new org.kuali.common.util.log4j.model.param.ConversionPatternParam(pattern);
75 org.kuali.common.util.log4j.model.Layout layout = new org.kuali.common.util.log4j.model.Layout(PatternLayout.class, param);
76 org.kuali.common.util.log4j.model.Appender console = new org.kuali.common.util.log4j.model.Appender(STDOUT, ConsoleAppender.class, layout);
77 org.kuali.common.util.log4j.model.AppenderRef ref = new org.kuali.common.util.log4j.model.AppenderRef(console.getName());
78 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));
79 return new org.kuali.common.util.log4j.model.Log4JContext(console, root, true);
80 }
81 }