Hi Dave, Some appenders allow you specify a 'layout' class to be used which is responsible for rendering/formatting each log message. Examples include HTMLLayout, XMLLayout and the PatternLayout you've been using.
The main advantage of the PatternLayout is that it lets you configure the ConversionPattern property to change the format of the log messages. Other layouts render to a fixed format e.g. XMLLayout, SimpleLayout, TTCLayout etc. What is the motivation for requiring xml output? If it is so that log files can be parsed/transformed remotely then surely you would want the format to be fixed i.e. complying with some dtd/xsd. The XMLLayout works fine for me although it is not the most human readable xml! It works because its format complies with the dtd (contained in the log4.jar in org\apache\log4j\xml\log4j.dtd) and therefore I can validate it and transform it into any format I like. Hope this helps. Regards Andy > -----Original Message----- > From: Dave Pawson [mailto:[EMAIL PROTECTED] > Sent: 26 April 2005 17:18 > To: [EMAIL PROTECTED] > Cc: 'Log4J Users List' > Subject: RE: Writing log in xml format > > On Mon, 2005-04-25 at 21:39 +0100, Andy McBride wrote: > > Dave, > > > > Are you referring to: > > http://marc.theaimsgroup.com/?l=log4j-user&m=111401761531451&w=2 > > > > If so it appears that you are trying to use the PatternLayout class to > > render a custom format xml document? > > Yes, I've a nasty habit of using XML tools on things like this :-) > > > > The XMLLayout class pointed out by Hakan, renders log events as xml > > conforming to the log4j.dtd. > .... I thought that was for the configuration file, not the output > of the logger. > Now I am confused. > > Use of this does not require you to have xml > > markup in the config file (.properties or.xml) as its format is fixed > > (I'm less keen on that, I like the configurability of log4j :-) > > > > > If I wanted a custom xml representation of log events, I would consider > > subclassing XMLLayout and overriding the format(Writer output, > LoggingEvent > > event) method, or do you have other requirements? > > .... I don't know yet Andy, since I haven't come across a way of > getting XML output from log4j. > (and I'm having trouble parsing the above sentence! I can hack up > tomcat pages, java tools, but that sounds like hard sums! > http://logging.apache.org/log4j/docs/api/org/apache/log4j/xml/XMLLayout.ht > ml > > Is that it? (Note that the link to the log4j.dtd is 404) > How do I select XML output.... > I'll go do some digging. > > Thanks Andy. > > regards DaveP > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
