繁体   English   中英

如何在log4j配置中包括日期

[英]How to include Date in log4j configuration

这是我在服务器中看到的当前日志记录:

12:40:10,190 | INFO  | -549263035-19951 | ServiceImpl    | Upload started
12:40:12,912 | INFO  | -549263035-19960 | ServiceImpl    | Upload started
12:40:12,915 | INFO  | -549263035-19958 | ServiceImpl    | Upload started

My application is using log4j to implement logging. here is the log4j.properties file which is sitting inside META-INF. 

log4j.rootCategory=DEBUG, O
log4j.appender.O=org.apache.log4j.ConsoleAppender
log4j.appender.O.layout=org.apache.log4j.PatternLayout
log4j.appender.O.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n


As we can clearly see, current logging has the time information for every event. I wanted to know if there is a way I could make some changes in this properties file or elsewhere to include the full timestamp i.e. Date and time both.

像:2013-07-18 12:40:12 | 信息| -549263035-19958 | ServiceImpl | 上传开始

Thanks for suggestion.

找到了我的答案。 此应用程序已部署在Servicemix容器中。 大约在servicemix的安装目录中,我找到了此配置文件。 “ /usr/local/servicemix/etc/org.ops4j.pax.logging.cfg”。

在此文件中,有一个SiftingAppender使用%d [ABSOLUTE]作为转换模式。 因此,基本上,在servicemix下部署的每个捆绑包都将使用此“ siftingappender”属性。 我刚刚从此配置文件中删除了[ABSOLUTE],并开始在日志中获取日期。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM