0

I'm using log4j for my logging purposes and all my log files in .log format, which is simply structured like;

INFO [2012-05-08 09:57:57,919] [main] create table Employee passed.

I have heard that the logfile can be outputted in an xml format but coudn't find the exact configuration.

log4j.rootCategory=INFO, C, R

log4j.appender.C = org.apache.log4j.ConsoleAppender

log4j.appender.C.layout = org.apache.log4j.PatternLayout

log4j.appender.C.layout.ConversionPattern = %5p [%d] [%t] %m%n

log4j.appender.R = org.apache.log4j.DailyRollingFileAppender

log4j.appender.R.layout=org.apache.log4j.PatternLayout

log4j.appender.R.layout.ConversionPattern= [%d] [%t] %5p %c %x - %m%n

log4j.appender.R.File = logs/test_suite.log

log4j.appender.R.DatePattern = '.'yyyyMMdd

Community
  • 1
  • 1
Madz
  • 1,273
  • 2
  • 18
  • 35
  • 2
    Not to mess with your question but if you start a new project, I suggest you take a look at slf4j which is log4j modern successor – frno May 09 '12 at 08:25

1 Answers1

1

Use org.apache.log4j.xml.XMLLayout as an appender layout. This creates log entries in the <log4j:event /> tag.

I believe that this Layout is introduced from Log4J 4.2.16 and upwards, but I might be wrong.

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228