2013-07-18 39 views
0

这里是我的服务器我看到当前的记录:如何包括log4j配置日期

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年7月18日12时40分十二秒| INFO | -549263035-19958 | ServiceImpl |开始上传

Thanks for suggestion. 
+0

我有感觉,你的记录器消息使用的不是你发布的布局,你能否以某种方式改变你的模式(例如删除[%d {ISO8601}]),并确保你的记录输出会改变。 – nkukhar

+0

我经历了文档,看起来你是对的,我的日志不使用这种布局。因为%d后跟ISO8601也应该记录日期。我假设我部署此应用程序的服务器使用的是优先于它的不同日志记录方案。但我不知道如何解决这个问题。 – Ashish

+0

thanx为您的输入 – Ashish

回答

0

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

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