How do I format to a specific pattern using Log4j?
2 answers
Use the following transformation pattern: "%m: %d{yyyy-MM-dd HH:mm:ss}%n"
no quotes. If you want to use ConsoleAppender your file log4j.properties
will 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
+7
a source to share