常用配置文件模板
1.log4j property格式
2.log4j XML格式
3.ANT build.xml
1
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
2 # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
3 log4j.rootLogger = WARN , stdout , logfile
4
5
6 #log4j.logger.org.springframework.aop.framework.autoproxy = DEBUG
7 #log4j.logger.org.springframework.aop.framework.autoproxy.metadata = DEBUG
8 #log4j.logger.org.springframework.aop.framework.autoproxy.target = DEBUG
9 #log4j.logger.org.springframework.transaction.interceptor = DEBUG
10 #log4j.logger.org.acegisecurity.intercept = DEBUG
11 #log4j.logger.org.acegisecurity.intercept.method = DEBUG
12 #log4j.logger.org.acegisecurity.intercept.web = DEBUG
13 #log4j.logger.org.acegisecurity.afterinvocation = DEBUG
14 #log4j.logger.org.acegisecurity.acl = DEBUG
15 #log4j.logger.org.acegisecurity.acl.basic = DEBUG
16 #log4j.logger.org.acegisecurity.acls.sid = DEBUG
17 #log4j.logger.org.acegisecurity.taglibs.authz = DEBUG
18 #log4j.logger.org.acegisecurity.ui.basicauth = DEBUG
19 #log4j.logger.org.acegisecurity.ui.rememberme = DEBUG
20 #log4j.logger.org.acegisecurity.ui = DEBUG
21 #log4j.logger.org.acegisecurity.afterinvocation = DEBUG
22 #log4j.logger.org.acegisecurity.ui.rmi = DEBUG
23 #log4j.logger.org.acegisecurity.ui.httpinvoker = DEBUG
24 #log4j.logger.org.acegisecurity.util = DEBUG
25 #log4j.logger.org.acegisecurity.providers.dao = DEBUG
26 #log4j.logger.org.acegisecurity = DEBUG , stdout , logfile
27 #log4j.logger.com.whwater.hr.waf.security.intercept.web = DEBUG
28 log4j.logger.sample.security = DEBUG
29 log4j.logger.sample.menu = DEBUG
30 log4j.logger.net.sf.navigator = DEBUG
31
32
33 # Console output
34 log4j.appender.stdout = org.apache.log4j.ConsoleAppender
35 log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
36 log4j.appender.stdout.layout.ConversionPattern = %d %p [ %c ] - %m%n
37
38 # Rolling log file output
39 log4j.appender.logfile = org.apache.log4j.RollingFileAppender
40 log4j.appender.logfile.File = ${testAcegi.root}/WEB-INF/testAcegiLog.html
41 log4j.appender.logfile.MaxFileSize = 512KB
42 # Keep three backup files.
43 log4j.appender.logfile.MaxBackupIndex = 1
44 # Pattern to output: date priority [ category ] - message
45 log4j.appender.logfile.layout = com.whwater.hr.waf.log4j.HTMLLayout
46 log4j.appender.logfile.layout.locationInfo = true
47
2 # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
3 log4j.rootLogger = WARN , stdout , logfile
4
5
6 #log4j.logger.org.springframework.aop.framework.autoproxy = DEBUG
7 #log4j.logger.org.springframework.aop.framework.autoproxy.metadata = DEBUG
8 #log4j.logger.org.springframework.aop.framework.autoproxy.target = DEBUG
9 #log4j.logger.org.springframework.transaction.interceptor = DEBUG
10 #log4j.logger.org.acegisecurity.intercept = DEBUG
11 #log4j.logger.org.acegisecurity.intercept.method = DEBUG
12 #log4j.logger.org.acegisecurity.intercept.web = DEBUG
13 #log4j.logger.org.acegisecurity.afterinvocation = DEBUG
14 #log4j.logger.org.acegisecurity.acl = DEBUG
15 #log4j.logger.org.acegisecurity.acl.basic = DEBUG
16 #log4j.logger.org.acegisecurity.acls.sid = DEBUG
17 #log4j.logger.org.acegisecurity.taglibs.authz = DEBUG
18 #log4j.logger.org.acegisecurity.ui.basicauth = DEBUG
19 #log4j.logger.org.acegisecurity.ui.rememberme = DEBUG
20 #log4j.logger.org.acegisecurity.ui = DEBUG
21 #log4j.logger.org.acegisecurity.afterinvocation = DEBUG
22 #log4j.logger.org.acegisecurity.ui.rmi = DEBUG
23 #log4j.logger.org.acegisecurity.ui.httpinvoker = DEBUG
24 #log4j.logger.org.acegisecurity.util = DEBUG
25 #log4j.logger.org.acegisecurity.providers.dao = DEBUG
26 #log4j.logger.org.acegisecurity = DEBUG , stdout , logfile
27 #log4j.logger.com.whwater.hr.waf.security.intercept.web = DEBUG
28 log4j.logger.sample.security = DEBUG
29 log4j.logger.sample.menu = DEBUG
30 log4j.logger.net.sf.navigator = DEBUG
31
32
33 # Console output
34 log4j.appender.stdout = org.apache.log4j.ConsoleAppender
35 log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
36 log4j.appender.stdout.layout.ConversionPattern = %d %p [ %c ] - %m%n
37
38 # Rolling log file output
39 log4j.appender.logfile = org.apache.log4j.RollingFileAppender
40 log4j.appender.logfile.File = ${testAcegi.root}/WEB-INF/testAcegiLog.html
41 log4j.appender.logfile.MaxFileSize = 512KB
42 # Keep three backup files.
43 log4j.appender.logfile.MaxBackupIndex = 1
44 # Pattern to output: date priority [ category ] - message
45 log4j.appender.logfile.layout = com.whwater.hr.waf.log4j.HTMLLayout
46 log4j.appender.logfile.layout.locationInfo = true
47
2.log4j XML格式
1
<?
xml version="1.0" encoding="UTF-8"
?>
2 <! DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
3
4 <!-- ===================================================================================== -->
5 <!-- Warning: the loggers of log4j has inheritable ability,the rootLogger is the root of -->
6 <!-- logger ,so the chind of it needn't writed like this:debug, stdout, logfile, just do -->
7 <!-- it like this:debug, the detail reason can see my blog:http://www.blogjava.net/jhonney -->
8 <!-- ===================================================================================== -->
9
10 < log4j:configuration xmlns:log4j ="http://jakarta.apache.org/log4j/" >
11
12 <!-- ================================================================= -->
13 <!-- a html file appender -->
14 <!-- html format. DO NOT use it on product environment. -->
15 <!-- ================================================================= -->
16
17 < appender name ="AHTML"
18 class ="org.apache.log4j.RollingFileAppender" >
19 < param name ="Threshold" value ="DEBUG" />
20 < param name ="File" value ="${hrwaf.root}/WEB-INF/waflog.html" />
21 < param name ="Append" value ="false" />
22 < param name ="MaxFileSize" value ="1024KB" />
23 < param name ="MaxBackupIndex" value ="10" />
24 < layout class ="com.whwater.hr.waf.log4j.HTMLLayout" >
25 < param name ="locationInfo" value ="true" />
26 </ layout >
27 </ appender >
28
29 <!-- ================================================================= -->
30 <!-- a xml file appender -->
31 <!-- xml format. -->
32 <!-- ================================================================= -->
33 < appender name ="AXML" class ="org.apache.log4j.FileAppender" >
34 < param name ="Threshold" value ="INFO" />
35 < param name ="File" value ="waflog.xml" />
36 < param name ="Append" value ="true" />
37 < layout class ="com.whater.hr.waf.log4j.XMLLayout" ></ layout >
38 </ appender >
39
40 <!-- ================================================================= -->
41 <!-- a console appender -->
42 <!-- self-defined format. -->
43 <!-- ================================================================= -->
44 < appender name ="ACONSOLE"
45 class ="org.apache.log4j.ConsoleAppender" >
46 < layout class ="com.whwater.hr.waf.log4j.ConsoleLayout" >
47 < param name ="locationInfo" value ="true" />
48 </ layout >
49 </ appender >
50
51 <!-- ================================================================= -->
52 <!-- a console appender -->
53 <!-- original format. -->
54 <!-- ================================================================= -->
55 < appender name ="console.log"
56 class ="org.apache.log4j.ConsoleAppender" >
57 < layout class ="org.apache.log4j.PatternLayout" >
58 < param name ="ConversionPattern"
59 value ="%d [%t] %l%n[%p] %m%n" />
60 </ layout >
61 </ appender >
62
63 < category name ="com.whwater.hr.waf" >
64 < priority value ="DEBUG" />
65 </ category >
66
67 < category name ="app2" >
68 < priority value ="DEBUG" />
69 </ category >
70
71 < root >
72 < level value ="error" />
73 < appender-ref ref ="ACONSOLE" />
74 < appender-ref ref ="AHTML" />
75 </ root >
76
77 </ log4j:configuration >
78
2 <! DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
3
4 <!-- ===================================================================================== -->
5 <!-- Warning: the loggers of log4j has inheritable ability,the rootLogger is the root of -->
6 <!-- logger ,so the chind of it needn't writed like this:debug, stdout, logfile, just do -->
7 <!-- it like this:debug, the detail reason can see my blog:http://www.blogjava.net/jhonney -->
8 <!-- ===================================================================================== -->
9
10 < log4j:configuration xmlns:log4j ="http://jakarta.apache.org/log4j/" >
11
12 <!-- ================================================================= -->
13 <!-- a html file appender -->
14 <!-- html format. DO NOT use it on product environment. -->
15 <!-- ================================================================= -->
16
17 < appender name ="AHTML"
18 class ="org.apache.log4j.RollingFileAppender" >
19 < param name ="Threshold" value ="DEBUG" />
20 < param name ="File" value ="${hrwaf.root}/WEB-INF/waflog.html" />
21 < param name ="Append" value ="false" />
22 < param name ="MaxFileSize" value ="1024KB" />
23 < param name ="MaxBackupIndex" value ="10" />
24 < layout class ="com.whwater.hr.waf.log4j.HTMLLayout" >
25 < param name ="locationInfo" value ="true" />
26 </ layout >
27 </ appender >
28
29 <!-- ================================================================= -->
30 <!-- a xml file appender -->
31 <!-- xml format. -->
32 <!-- ================================================================= -->
33 < appender name ="AXML" class ="org.apache.log4j.FileAppender" >
34 < param name ="Threshold" value ="INFO" />
35 < param name ="File" value ="waflog.xml" />
36 < param name ="Append" value ="true" />
37 < layout class ="com.whater.hr.waf.log4j.XMLLayout" ></ layout >
38 </ appender >
39
40 <!-- ================================================================= -->
41 <!-- a console appender -->
42 <!-- self-defined format. -->
43 <!-- ================================================================= -->
44 < appender name ="ACONSOLE"
45 class ="org.apache.log4j.ConsoleAppender" >
46 < layout class ="com.whwater.hr.waf.log4j.ConsoleLayout" >
47 < param name ="locationInfo" value ="true" />
48 </ layout >
49 </ appender >
50
51 <!-- ================================================================= -->
52 <!-- a console appender -->
53 <!-- original format. -->
54 <!-- ================================================================= -->
55 < appender name ="console.log"
56 class ="org.apache.log4j.ConsoleAppender" >
57 < layout class ="org.apache.log4j.PatternLayout" >
58 < param name ="ConversionPattern"
59 value ="%d [%t] %l%n[%p] %m%n" />
60 </ layout >
61 </ appender >
62
63 < category name ="com.whwater.hr.waf" >
64 < priority value ="DEBUG" />
65 </ category >
66
67 < category name ="app2" >
68 < priority value ="DEBUG" />
69 </ category >
70
71 < root >
72 < level value ="error" />
73 < appender-ref ref ="ACONSOLE" />
74 < appender-ref ref ="AHTML" />
75 </ root >
76
77 </ log4j:configuration >
78
3.ANT build.xml
1
<?
xml version="1.0"
?>
2
3 < project name ="LightWeightContainer" default ="all" basedir ="." >
4
5 <!-- properies -->
6 < property name ="src.dir" value ="src" />
7 < property name ="classes.dir" value ="classes" />
8 < property name ="lib.dir" value ="lib" />
9 < property name ="dist.dir" value ="dist" />
10 < property name ="version" value ="1.5" />
11
12 <!-- 定义classpath -->
13 < path id ="master-classpath" >
14 < fileset file ="${lib.dir}/*.jar" />
15 < fileset file ="${lib.dir}/log4j.properties" />
16 < pathelement path ="${classes.dir}" />
17 </ path >
18
19 < target name ="all" depends ="pack" >
20 < delete dir ="${classes.dir}" />
21 < delete dir ="${samples.dir}" />
22 </ target >
23
24 < target name ="clean" >
25 <!-- Delete the ${build} and ${dist} directory trees -->
26 < delete dir ="${classes.dir}" />
27 < delete dir ="${dist.dir}" />
28 </ target >
29
30 <!-- 初始化任务 -->
31 < target name ="init" depends ="clean" >
32 </ target >
33
34 <!-- 编译 -->
35 < target name ="compile" depends ="init" description ="compile the source files" >
36 < mkdir dir ="${classes.dir}" />
37
38 < javac srcdir ="${src.dir}" destdir ="${classes.dir}" target ="${version}" debug ="true" encoding ="UTF-8"
39 fork ="true"
40 memoryInitialSize ="64m"
41 memoryMaximumSize ="128m" >
42 < classpath refid ="master-classpath" />
43 </ javac >
44
45 < copy todir ="${classes.dir}" overwrite ="true" >
46 < fileset dir ="${src.dir}" >
47 < include name ="**/*.xml" />
48 < include name ="**/*.properties" />
49 </ fileset >
50 </ copy >
51 < copy todir ="${classes.dir}/META-INF" overwrite ="true" >
52 < fileset dir ="${src.dir}/META-INF" >
53 < include name ="**/*.*" />
54 </ fileset >
55 </ copy >
56 < copy todir ="${classes.dir}/META-INF/tlds" overwrite ="true" >
57 < fileset dir ="${src.dir}/META-INF/tlds" >
58 < include name ="**/*.tld" />
59 </ fileset >
60 </ copy >
61 </ target >
62
63
64 <!-- 打包成jar -->
65 < target name ="pack" depends ="compile" description ="make .jar file" >
66 < mkdir dir ="${dist.dir}" />
67 < jar destfile ="${dist.dir}/lightWeightContainer.jar" basedir ="${classes.dir}" manifest ="${classes.dir}/META-INF/MANIFEST.MF" />
68 < copy todir ="${dist.dir}" >
69 < fileset dir ="${lib.dir}" >
70 < exclude name ="jakarta-regexp-1.1.jar" />
71 </ fileset >
72 </ copy >
73 </ target >
74 </ project >
75
76
2
3 < project name ="LightWeightContainer" default ="all" basedir ="." >
4
5 <!-- properies -->
6 < property name ="src.dir" value ="src" />
7 < property name ="classes.dir" value ="classes" />
8 < property name ="lib.dir" value ="lib" />
9 < property name ="dist.dir" value ="dist" />
10 < property name ="version" value ="1.5" />
11
12 <!-- 定义classpath -->
13 < path id ="master-classpath" >
14 < fileset file ="${lib.dir}/*.jar" />
15 < fileset file ="${lib.dir}/log4j.properties" />
16 < pathelement path ="${classes.dir}" />
17 </ path >
18
19 < target name ="all" depends ="pack" >
20 < delete dir ="${classes.dir}" />
21 < delete dir ="${samples.dir}" />
22 </ target >
23
24 < target name ="clean" >
25 <!-- Delete the ${build} and ${dist} directory trees -->
26 < delete dir ="${classes.dir}" />
27 < delete dir ="${dist.dir}" />
28 </ target >
29
30 <!-- 初始化任务 -->
31 < target name ="init" depends ="clean" >
32 </ target >
33
34 <!-- 编译 -->
35 < target name ="compile" depends ="init" description ="compile the source files" >
36 < mkdir dir ="${classes.dir}" />
37
38 < javac srcdir ="${src.dir}" destdir ="${classes.dir}" target ="${version}" debug ="true" encoding ="UTF-8"
39 fork ="true"
40 memoryInitialSize ="64m"
41 memoryMaximumSize ="128m" >
42 < classpath refid ="master-classpath" />
43 </ javac >
44
45 < copy todir ="${classes.dir}" overwrite ="true" >
46 < fileset dir ="${src.dir}" >
47 < include name ="**/*.xml" />
48 < include name ="**/*.properties" />
49 </ fileset >
50 </ copy >
51 < copy todir ="${classes.dir}/META-INF" overwrite ="true" >
52 < fileset dir ="${src.dir}/META-INF" >
53 < include name ="**/*.*" />
54 </ fileset >
55 </ copy >
56 < copy todir ="${classes.dir}/META-INF/tlds" overwrite ="true" >
57 < fileset dir ="${src.dir}/META-INF/tlds" >
58 < include name ="**/*.tld" />
59 </ fileset >
60 </ copy >
61 </ target >
62
63
64 <!-- 打包成jar -->
65 < target name ="pack" depends ="compile" description ="make .jar file" >
66 < mkdir dir ="${dist.dir}" />
67 < jar destfile ="${dist.dir}/lightWeightContainer.jar" basedir ="${classes.dir}" manifest ="${classes.dir}/META-INF/MANIFEST.MF" />
68 < copy todir ="${dist.dir}" >
69 < fileset dir ="${lib.dir}" >
70 < exclude name ="jakarta-regexp-1.1.jar" />
71 </ fileset >
72 </ copy >
73 </ target >
74 </ project >
75
76