commons-logging.jar
org.apache.commons.logging
log4j.jar
org.apache.log4j
都是apache开源组织的产物,实在是搞不懂为何要搞两个出来,但是一般都是将二者配合使用。
配置的时候需要把commons-logging.properties,log4j.properties放在classpath下,commons-logging.properties可以不需要,log4j.properties必须作配置至少配置。
配置文件:log4j.properties
#下面这句最重要
log4j.rootLogger = DEBUG, CONSOLE,stdout, logfile
log4j中的日志级别有有五级,分别是:
(1)FATAL 0 (致命的)
(2)ERROR 3 (错误)
(3)WARN 4 (警告)
(4)INFO 6 (消息)
(5)DEBUG 7 (排除错误、调试)
编程时候一般都这样写:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class MyClassTest{
private static Log log = LogFactory.getLog(MyClassTest. class );
public void test(){
log.fatal( "0-fatal " );
log.error( " 3-error" );
log.warn( " 4-warn " );
log.info( " 6-info" );
log.debug( " 7-debug" );
}
}
备用资料查询网址:
http://blog.csdn.net/cdtdx/archive/2007/11/05/1867567.aspx
http://www.nihaoblog.com/15_890.html
分享到:
相关推荐
为什么同时使用commons-logging和Log4j?commons-logging为我们提供了统一的日志接口,可以用各种日志工具类。log4j是目前输出日志的首选。
这是一个讲解commons-logging 和log4j的使用方法,里面有一些例子供大家参考。
官网下载,未作任何改动
NULL 博文链接:https://tianjun309.iteye.com/blog/776137
用户可以自由选择第三方的日志组件作为具体实现,像log4j,或者jdk自带的logging, common-logging会通过动态查找的机制,在程序运行时自动找出真正使用的日志库。当然,common-logging内部有一个Simple logger的...
NULL 博文链接:https://icourses.iteye.com/blog/1839984
Commons-loggin的目的是为“所有的Java日志实现”提供一个统一的接口,它自身的日志功能平常弱(只有一个简单的SimpleLog?...另外一个我能想到的“同时使用commons-logging和Log4j”的原因是,简化使用和配置
log4j日志包 log4j.jar\commons-logging-1.1.1.jar private static final Log log = LogFactory.getLog(xxxxxx.class); 下载后解压就能得到这两个包
配置日志文件时需要的jar包,配置日志文件时需要的jar包,配置日志文件时需要的jar包
log4j 用的两个jar包,log4j-1.2.14.jar 和 commons-logging-1.1.jar
开发工具 commons-logging-1.2开发工具 commons-logging-1.2开发工具 commons-logging-1.2开发工具 commons-logging-1.2开发工具 commons-logging-1.2开发工具 commons-logging-1.2开发工具 commons-logging-1.2开发...
poi-3.6-20091214.jar commons-logging-1.1
When writing a library it is very useful to log information. However there are many logging implementations out there, and a library cannot impose the use of a particular one on the overall ...
日志框架需要的Jar包 commons-logging.jar log4j.jar
log4j jdklog commons-logging 关系及简单应用 详情看blog http://blog.csdn.net/harrison2010/archive/2011/02/15/6185819.aspx
jar包大小:342KB log4j-1.2.6.jar jar包大小:135KB commons-validator-1.3.1.jar jar包大小:93KB commons-transaction-1.2.jar jar包大小:141KB commons-scxml-0.6.jar jar包大小:254KB commons-primitives-1.0.jar ...
commons-logging-1.0.4.jar、hessian-3.0.1.jar、log4j-1.2.12.jar
Commons Logging (JCL)提供的是一个日志(Log)接口(interface),同时兼顾轻量级和不依赖于具体的... Because we use commons-logging you are free to choose your logging implementation (Log4j is a common choice).
commons-logging配合log4j,java log ,打印输出日志必备
log4j 与commonslogging,搭配记录日志是现在最流行的记录日志的方法,两者搭配不仅没有增加日志记录的难度,反而大大简化了记录日志的操作。