commons-logging和apache-log4j的结合使用
来源:互联网 发布:mac连接wifi但不能上网 编辑:程序博客网 时间:2024/06/01 16:47
1.添加2个工具相关的jar包到工程
http://apache.etoak.com/logging/log4j/1.2.15/apache-log4j-1.2.15.zip
http://labs.renren.com/apache-mirror/commons/logging/binaries/commons-logging-1.1.1-bin.zip
2.为log4j编写配置文件,使用默认的文件名,如:log4j.xml或log4j.properties,因为log4j会自动去找这2个文件。放在classes目录下。
3.在代码中使用:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Log log = LogFactory.getLog("name");
log.info(obj);
////////////////////////////////////////////////////////////////////////////
///log4j.properties
## LOGGERS ##
#configure root logger
log4j.rootLogger=INFO,console
#define a logger named helloAppLogger
log4j.logger.helloappLogger=WARN
#define a second logger that is a child to helloAppLogger
log4j.logger.helloappLogger.childLogger=,file
#configure root logger
log4j.rootLogger=INFO,console
#define a logger named helloAppLogger
log4j.logger.helloappLogger=WARN
#define a second logger that is a child to helloAppLogger
log4j.logger.helloappLogger.childLogger=,file
## APPENDERS ##
# define an appender named console, which is set to be a ConsoleAppender
log4j.appender.console=org.apache.log4j.ConsoleAppender
# define an appender named console, which is set to be a ConsoleAppender
log4j.appender.console=org.apache.log4j.ConsoleAppender
# define an appender named file, which is set to be a RollingFileAppender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log.txt
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log.txt
## LAYOUTS ##
# assign a SimpleLayout to console appender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %c %p - %m%n
# assign a SimpleLayout to console appender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %c %p - %m%n
# assign a PatternLayout to file appender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %c %p - %m%n
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %c %p - %m%n
- commons-logging和apache-log4j的结合使用
- apache commons Logging与Log4j结合的使用
- apache commons Logging与Log4j结合的使用
- log4j+commons-logging结合使用
- log4j+commons-logging结合使用
- log4j+commons-logging结合使用
- log4j+commons-logging结合使用
- log4j+commons-logging结合使用
- apache commons-logging和log4j
- 使用commons.logging结合log4j显示调试和日志信息
- commons-logging-Log和Log4j的使用
- commons-logging结合log4j
- Apache通用日志工具commons-logging和Log4j使用总结
- Apache通用日志工具commons-logging和Log4j使用
- Apache通用日志工具commons-logging和Log4j使用总结
- Apache通用日志工具commons-logging和Log4j使用总结
- Apache通用日记工具commons-logging和Log4j使用总结
- Apache通用日志工具commons-logging和Log4j使用总结
- 利用jquery实现图片显隐特效
- c中的宏及预定义符##和#细析
- ssh + dwr 问题
- 新浪围脖@WPMind.com v0.1发布
- Catalina.stop: java.net.ConnectException: Connection refused 错误
- commons-logging和apache-log4j的结合使用
- Servlet乱码问题的解决
- Action中使用getServletContext()
- tomcat启动命令
- tomcat中添加新虚拟主机
- 管理的职能
- Web Service入门
- 可控Threadpool设计
- C# UDP 入门