spring中commons-logging.jar的作用
2014-03-21 21:06
549 查看
commons-logging.jar包是使用spring的必备包。(位置在spring-framework-2.5.6.SEC01\lib \jakarta-commons)用来记录程序运行时的活动的日志记录。
在java平台中,有几个可以选择的日志记录的实现(log4j,JDK Logging API)。
如果你希望你的日志记录与实现无关,你可以使用Apache Commons Logging,它使用抽象的API,这些API都是实现无关的,可以让你在不同的日志记录实现之间切换,而不需要修改你的代码。
只要你使用了Apache Commons Logging,你可以在Apache Commons Logging支持的日志记录实现任意选择(目前主要支持log4j和JDK Logging API),如果使用log4j,拷贝spring-framework-2.5.6.SEC01\lib\log4j下的包到程序里,一旦程序中检测 log4j在classpath,Commons Logging将会使用log4j作为底层实现。
你可以可以通过配置在classpath根目录下log4j.properties来配置Log4j。下面log4j配置文件定义了一个日志输出器 (log appender)叫做stdout,可以用来输出日志信息到控制台上。想了解更多的Log4J的信息。请参考Log4J
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=
%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n
### set root logger level ###
log4j.rootLogger=error, stdout
### set application logger level ###
log4j.logger.com.apress.springrecipes.calculator=info
Log4J支持根据紧急度从高到低分为6个日志等级-fatal, error, warn, info, debug, 和trace。在上面的配置文件中,程序的根日志级别是error,这就意味着只有error和fatal级别的日志才会默认输出。但是对于 com.apress.springrecipes.calculator包和它的子包,只要日志级别高于info才会输出。
在java平台中,有几个可以选择的日志记录的实现(log4j,JDK Logging API)。
如果你希望你的日志记录与实现无关,你可以使用Apache Commons Logging,它使用抽象的API,这些API都是实现无关的,可以让你在不同的日志记录实现之间切换,而不需要修改你的代码。
只要你使用了Apache Commons Logging,你可以在Apache Commons Logging支持的日志记录实现任意选择(目前主要支持log4j和JDK Logging API),如果使用log4j,拷贝spring-framework-2.5.6.SEC01\lib\log4j下的包到程序里,一旦程序中检测 log4j在classpath,Commons Logging将会使用log4j作为底层实现。
你可以可以通过配置在classpath根目录下log4j.properties来配置Log4j。下面log4j配置文件定义了一个日志输出器 (log appender)叫做stdout,可以用来输出日志信息到控制台上。想了解更多的Log4J的信息。请参考Log4J
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=
%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n
### set root logger level ###
log4j.rootLogger=error, stdout
### set application logger level ###
log4j.logger.com.apress.springrecipes.calculator=info
Log4J支持根据紧急度从高到低分为6个日志等级-fatal, error, warn, info, debug, 和trace。在上面的配置文件中,程序的根日志级别是error,这就意味着只有error和fatal级别的日志才会默认输出。但是对于 com.apress.springrecipes.calculator包和它的子包,只要日志级别高于info才会输出。
相关文章推荐
- spring中commons-logging.jar的作用
- spring中commons-logging.jar的作用
- spring中commons-logging.jar的作用
- spring开发中commons-logging.jar包的功能
- spring开发中commons-logging.jar包的功能
- spring 4.3.5导入commons-logging的jar包后报NoClassDefFoundError
- 在spring中引入commons-logging.jar包的目的
- 详解spring 每个jar的作用
- spring核心框架体系结构(各个jar包作用)
- 详解spring 每个jar的作用
- Spring各jar包的作用
- Spring的各个jar包的作用介绍
- 详解spring 每个jar的作用
- 详解spring 每个jar的作用
- 详解spring 每个jar的作用
- 使用struts未引用commons-logging.jar遇到的奇怪问题
- Spring各个jar报的作用与maven pom.xnl配置
- Spring配置中各个jar的作用详解
- spring核心框架体系结构(各个jar包作用)
- 详解 spring 每个jar的作用