aldream
BlogJava
首页
新随笔
联系
聚合
管理
1 Posts :: 10 Stories :: 1 Comments :: 0 Trackbacks
常用链接
我的随笔
我的评论
我的参与
最新评论
留言簿
(1)
给我留言
查看公开留言
查看私人留言
随笔档案
(1)
2007年11月 (1)
文章分类
(15)
css
eclipse(1)
html(1)
html dom
java(6)
JUnit(2)
Log4j(3)
web design
xhtml
xml
测试(2)
文章档案
(10)
2007年12月 (1)
2007年11月 (9)
相册
holly
java
BEA WebLogic Server 8.1 Documentation
javaranch
WebLogic Server 9.1 中文使用手册
搜索
最新评论
1. re: 与任何qq用户聊天
你还好吗
--于海
Log4j配置文件
下面的Log4J配置文件实现了输出到控制台、文件、回滚文件、发送日志邮件、输出到数据库日志表、自定义标签等全套功能。
1
log4j.rootLogger
=
DEBUG
,
CONSOLE
,
A1
,
im
2
log4j.addivity.org.apache
=
true
3
# 应用于控制台
4
log4j.appender.CONSOLE
=
org.apache.log4j.ConsoleAppender
5
log4j.appender.Threshold
=
DEBUG
6
log4j.appender.CONSOLE.Target
=
System.out
7
log4j.appender.CONSOLE.Encoding
=
GBK
8
log4j.appender.CONSOLE.layout
=
org.apache.log4j.PatternLayout
9
log4j.appender.CONSOLE.layout.ConversionPattern
=
[
framework
]
%d - %c -%-4r
[
%t
]
%-5p %c %x - %m%n
10
#log4j.appender.CONSOLE.layout.ConversionPattern
=
[
start
]
%d{DATE}
[
DATE
]
%n%p
[
PRIORITY
]
%n%x
[
NDC
]
%n%t
[
THREAD
]
n%c
[
CATEGORY
]
%n%m
[
MESSAGE
]
%n%n
11
#应用于文件
12
log4j.appender.FILE
=
org.apache.log4j.FileAppender
13
log4j.appender.FILE.File
=
file.log
14
log4j.appender.FILE.Append
=
false
15
log4j.appender.FILE.Encoding
=
GBK
16
log4j.appender.FILE.layout
=
org.apache.log4j.PatternLayout
17
log4j.appender.FILE.layout.ConversionPattern
=
[
framework
]
%d - %c -%-4r
[
%t
]
%-5p %c %x - %m%n
18
# Use this layout for LogFactor
5
analysis
19
# 应用于文件回滚
20
log4j.appender.ROLLING_FILE
=
org.apache.log4j.RollingFileAppender
21
log4j.appender.ROLLING_FILE.Threshold
=
ERROR
22
log4j.appender.ROLLING_FILE.File
=
rolling.log
23
log4j.appender.ROLLING_FILE.Append
=
true
24
log4j.appender.CONSOLE_FILE.Encoding
=
GBK
25
log4j.appender.ROLLING_FILE.MaxFileSize
=
10KB
26
log4j.appender.ROLLING_FILE.MaxBackupIndex
=
1
27
log4j.appender.ROLLING_FILE.layout
=
org.apache.log4j.PatternLayout
28
log4j.appender.ROLLING_FILE.layout.ConversionPattern
=
[
framework
]
%d - %c -%-4r
[
%t
]
%-5p %c %x - %m%n
29
#应用于socket
30
log4j.appender.SOCKET
=
org.apache.log4j.RollingFileAppender
31
log4j.appender.SOCKET.RemoteHost
=
localhost
32
log4j.appender.SOCKET.Port
=
5001
33
log4j.appender.SOCKET.LocationInfo
=
true
34
# Set up for Log Facter
5
35
log4j.appender.SOCKET.layout
=
org.apache.log4j.PatternLayout
36
log4j.appender.SOCET.layout.ConversionPattern
=
[
start
]
%d{DATE}
[
DATE
]
%n%p
[
PRIORITY
]
%n%x
[
NDC
]
%n%t
[
THREAD
]
%n%c
[
CATEGORY
]
%n%m
[
MESSAGE
]
%n%n
37
# Log Factor
5
Appender
38
log4j.appender.LF5_APPENDER
=
org.apache.log4j.lf5.LF5Appender
39
log4j.appender.LF5_APPENDER.MaxNumberOfRecords
=
2000
40
# 发送日志给邮件
41
log4j.appender.MAIL
=
org.apache.log4j.net.SMTPAppender
42
log4j.appender.MAIL.Threshold
=
FATAL
43
log4j.appender.MAIL.BufferSize
=
10
44
log4j.appender.MAIL.From
=
web@www.wuset.com
45
log4j.appender.MAIL.SMTPHost
=
www.wusetu.com
46
log4j.appender.MAIL.Subject
=
Log4J Message
47
log4j.appender.MAIL.To
=
web@www.wusetu.com
48
log4j.appender.MAIL.layout
=
org.apache.log4j.PatternLayout
49
log4j.appender.MAIL.layout.ConversionPattern
=
[
framework
]
%d - %c -%-4r
[
%t
]
%-5p %c %x - %m%n
50
# 用于数据库
51
log4j.appender.DATABASE
=
org.apache.log4j.jdbc.JDBCAppender
52
log4j.appender.DATABASE.URL
=
jdbc:mysql://localhost:
3306
/test
53
log4j.appender.DATABASE.driver
=
com.mysql.jdbc.Driver
54
log4j.appender.DATABASE.user
=
root
55
log4j.appender.DATABASE.password
=
56
log4j.appender.DATABASE.sql
=
INSERT INTO LOG4J (Message) VALUES ('
[
framework
]
%d - %c -%-4r
[
%t
]
%-5p %c %x - %m%n')
57
log4j.appender.DATABASE.layout
=
org.apache.log4j.PatternLayout
58
log4j.appender.DATABASE.layout.ConversionPattern
=
[
framework
]
%d - %c -%-4r
[
%t
]
%-5p %c %x - %m%n
59
# 每天新建日志
60
log4j.appender.A1
=
org.apache.log4j.DailyRollingFileAppender
61
log4j.appender.A1.File
=
log
62
log4j.appender.A1.Encoding
=
GBK
63
log4j.appender.A1.DatePattern
=
'.'yyyy-MM-dd
64
log4j.appender.A1.layout
=
org.apache.log4j.PatternLayout
65
log4j.appender.A1.layout.ConversionPattern
=
%d{ABSOLUTE} %5p %c{
1
}:%L : %m%n
66
#自定义Appender
67
log4j.appender.im
=
net.cybercorlin.util.logger.appender.IMAppender
68
log4j.appender.im.host
=
mail.cybercorlin.net
69
log4j.appender.im.username
=
username
70
log4j.appender.im.password
=
password
71
log4j.appender.im.recipient
=
corlin@cybercorlin.net
72
log4j.appender.im.layout
=
org.apache.log4j.PatternLayout
73
log4j.appender.im.layout.ConversionPattern
=
[
framework
]
%d - %c -%-4r
[
%t
]
%-5p %c %x - %m%n
posted on 2007-11-10 00:43
aldream
阅读(242)
评论(0)
编辑
收藏
所属分类:
java
、
Log4j
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
Chat2DB
C++博客
博问
管理
相关文章:
eclipse Junit测试向导
在eclipse调试JSP和java程序
嵌套诊断环境NDC
一个Junit例子(转自caterpillar.onlyfun.net)
Log4j优化
Log4j配置文件
Powered by:
BlogJava
Copyright © aldream