ITKeyword,专注技术干货聚合推荐

注册 | 登录

SSH框架中的log4j完美配置

luo_yifan 分享于 2012-05-08

推荐:SSH框架中使用log4j的方便之处(将log4j配置文件改在WEF-INF下面)

1. 动态的改变记录级别和策略,即修改log4j.properties,不需要重启Web应用,这需要在web.xml中设置一下。 2. 把log文件定在 /WEB-INF/logs/ 而不需要写绝对路径

2019阿里云全部产品优惠券(新购或升级都可以使用,强烈推荐)
领取地址https://promotion.aliyun.com/ntms/yunparter/invite.html

#@not support hotloading
# For JBoss:  Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
# For  all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
#
# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging)
#
# The five logging levels used by Log are (in order):
#
#   1. DEBUG (the least serious)
#   2. INFO
#   3. WARN
#   4. ERROR
#   5. FATAL (the most serious)
# Set root logger level to WARN and append to stdout

# root stuff
log4j.rootLogger=INFO,logfile,stdout
# OpenSymphony Stuff
log4j.logger.com.opensymphony=INFO,logfile,stdout
# Struts2 Stuff
log4j.logger.org.apache.struts2=INFO,logfile,stdout
# Spring Stuff
log4j.logger.org.springframework=INFO,logfile,stdout
# Hibernate Stuff
log4j.logger.org.hibernate=INFO,logfile,stdout
# Own Stuff
log4j.logger.com.roger = INFO,logfile,stdout

### 后台控制台的打印 ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =  %d{ABSOLUTE} %5p %c{1}:%L - %m%n

# the config for report
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=${catalina.base}/logs/ActivityManage.log
log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
log4j.appender.logfile.Append=true
log4j.appender.logfile.Threshold=DEBUG
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}]%-5p %l [%t] %m%n


 

推荐:SSH框架学习(五、加入log4j)

原文转自:http://blog.csdn.net/wuyt2008/article/details/8244195 log4j是个很多人喜欢用的日志工具,随大流咯。 log4j的最新版是2.0-beat3,稳妥起见,我用了

#@not support hotloading# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!# For all other servers: Comment out the Log4J listener in web.x

相关阅读排行


用户评论

游客

相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。