本文介绍了如何使用Log4j格式化为特定模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过以下方式捕获log4j日志注释.是否可以 ?如果是这样,那么我的 log4j.properties 应该如何??
I want to capture the log4j logging comments in the following way. Is it possible ? If so then how should my log4j.properties look like ??
我的消息:2009-05-22 17:07:28
My Message : 2009-05-22 17:07:28
谢谢溜冰场
推荐答案
使用以下转换模式:%m:%d {yyyy-MM-dd HH:mm:ss}%n"
不带引号.如果要使用ConsoleAppender,您的 log4j.properties
文件将包含:
Use the following conversion pattern: "%m: %d{yyyy-MM-dd HH:mm:ss}%n"
without the quotes.If you wanted to use ConsoleAppender, your log4j.properties
file would contain:
log4j.rootLogger=debug, CON
log4j.appender.CON=org.apache.log4j.ConsoleAppender
log4j.appender.CON.layout=org.apache.log4j.PatternLayout
log4j.appender.CON.layout.ConversionPattern=%m: %d{yyyy-MM-dd HH:mm:ss}%n
这篇关于如何使用Log4j格式化为特定模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!