简体   繁体   中英

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 | INFO | -549263035-19958 | ServiceImpl | Upload started

Thanks for suggestion.

Found my answer. this application was deployed in Servicemix container. Apparantly inside servicemix's installation directory I found this configuration file. "/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. So basically every bundle which is deployed under servicemix is going to use this "siftingappender" properties. I just removed [ABSOLUTE] from this configuration file and started getting the Date in my logs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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