在Spring中配置使用commons-logging的simplelog来输出日志

烦透了log4j,最新版的包结构变动也不做下兼容,在spring项目中用会爆找不到class,maven仓中的老版又依赖了一大堆Java1.4的东西,实在是不爽,于是果断抛弃,改用commons-logging的simplelog来输出日志。

要在spring中使用simplelog输出日志,需要在classpath中放入两个properties:commons-logging.properties和simplelog.properties

commons-logging.properties:

org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog

simplelog.properties:

#Set to true if you want the Log instance name to be included in output messages. Defaults to false.
org.apache.commons.logging.simplelog.showlogname=true

#Set to true if you want the last component of the name to be included in output messages. Defaults to true.
#org.apache.commons.logging.simplelog.showShortLogname=false

#Set to true if you want the current date and time to be included in output messages. Default is false.
org.apache.commons.logging.simplelog.showdatetime=true

#The date and time format to be used in the output messages. The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. If the format is not specified or is invalid, the default format is used. The default format is yyyy/MM/dd HH:mm:ss:SSS zzz.
#org.apache.commons.logging.simplelog.dateTimeFormat=yyyy/MM/dd HH:mm:ss:SSS zzz

#Default logging detail level for all instances of SimpleLog. Must be one of: trace debug info warn error fatal If not specified, defaults to info.
#org.apache.commons.logging.simplelog.defaultlog=debug

## Configure logging levels
org.apache.commons.logging.simplelog.log.org.springframework.jdbc=trace
    原文作者:since1986
    原文地址: https://segmentfault.com/a/1190000000768381
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞