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

本文介绍如何在Spring框架中配置并使用SimpleLog进行日志记录。通过设置commons-logging.properties和simplelog.properties文件,可以自定义日志级别、日期格式等细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Spring中使用自带的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


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值