简体   繁体   English

如何在log4j配置中包括日期

[英]How to include Date in log4j configuration

here is the current logging which I am seeing in Server: 这是我在服务器中看到的当前日志记录:

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.

something like : 2013-07-18 12:40:12 | 像:2013-07-18 12:40:12 | INFO | 信息| -549263035-19958 | -549263035-19958 | ServiceImpl | ServiceImpl | Upload started 上传开始

Thanks for suggestion.

Found my answer. 找到了我的答案。 this application was deployed in Servicemix container. 此应用程序已部署在Servicemix容器中。 Apparantly inside servicemix's installation directory I found this configuration file. 大约在servicemix的安装目录中,我找到了此配置文件。 "/usr/local/servicemix/etc/org.ops4j.pax.logging.cfg". “ /usr/local/servicemix/etc/org.ops4j.pax.logging.cfg”。

Inside this file, there was a SiftingAppender which was using %d[ABSOLUTE] as a conversion pattern. 在此文件中,有一个SiftingAppender使用%d [ABSOLUTE]作为转换模式。 So basically every bundle which is deployed under servicemix is going to use this "siftingappender" properties. 因此,基本上,在servicemix下部署的每个捆绑包都将使用此“ siftingappender”属性。 I just removed [ABSOLUTE] from this configuration file and started getting the Date in my logs. 我刚刚从此配置文件中删除了[ABSOLUTE],并开始在日志中获取日期。

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

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