tags:

views:

102

answers:

3
+1  Q: 

Log4j Question

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 ??

My Message : 2009-05-22 17:07:28

Thanks Rink

A: 

are you saying you want to flip the time and message parts??

this should have been a comment, not an answer
idrosid
AK cannot comment yet, not enough reputation
Salandur
Maybe SO could detect single sentence answers ending in a question mark and flash up a warning?
Simon Gibbs
+3  A: 

Add following lines in your log4j.properties file:

log4j.appender.stdout.layout.ConversionPattern=MyMessage : %-5p %d{yyyy-MMM-dd   HH:mm:ss,SSS} %m %n

log4j.appender.R.layout.ConversionPattern=MyMessage : %-5p %d{yyyy-MMM-dd   HH:mm:ss,SSS} %m %n
Green Techy
+3  A: 

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
Ceki