hyljava

log4j的简单配置

 首先导入两个包:  commons-logging.jar  log4j-1.2.12.jar

   在src下编写3个 properties文件

1.log4j.properties 下面是内容


##LOGGERS

#define a logger
log4j.rootLogger=INFO,console,file

##APPENDERS
#define an appender named console
log4j.appender.console=org.apache.log4j.ConsoleAppender
#define an appender named file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=d:/demo_log.txt
#set the log's size
log4j.appender.file.MaxFileSize=1000KB
log4j.appender.file.MaxBackupIndex=20

##LAYOUTS
#assign a SimpleLayout to console appender
log4j.appender.console.layout=org.apache.log4j.SimpleLayout
#assign a PatternLayout to file appender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%-5p][%d{yyyy-MM-dd HH:mm:ss}]%m%n

 

2.
    simplelog.properties下面是内容


log.apache.commons.logging.simplelog.defaultlog=info

3.
    commons-logging.properties下面是内容

##set Log as Log4J
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

 

 

posted on 2012-05-28 19:04 何云隆 阅读(311) 评论(0)  编辑  收藏 所属分类: HibernateStruts1spring


只有注册用户登录后才能发表评论。


网站导航: