If you intend to parse the log output and extract information from it then I 
would lean towards using the XmlLayout as this is a parsable format. You never 
can tell what text will be output from the PatternLayout and as it does not 
escaping relying on start and end markers is always a little risky.

However as it is simple to add support for an exception pattern layout I will 
add it to CVS.
Essentially the behaviour of the following two patters will be identical:

"%message%newline"

and

"%message%newline%exception" 

This is because the IgnoresException will be set to false if the %exception 
converter is included in the pattern. The %exception converter will output 
nothing if no exception is set. If an exception is set then it will output the 
exception string representation followed by a newline.

Nicko

> -----Original Message-----
> From: Ceki G�lc� [mailto:[EMAIL PROTECTED] 
> Sent: 16 September 2004 19:43
> To: Log4NET Dev
> Subject: Re: Parsing of log files from 
> FileAppender/Supporting exceptions in the PatternLayout
> 
> 
> Hello,
> 
> In the current (log4j) code, if you are using the 
> PatternLayout, exceptions are handled by the appender instead 
> of the PatternLayout. At the time, it was assumed that the 
> user would always want to see the exception and it would be 
> error prone for force the user to specify an exception 
> converter, say %e, at the end of the conversion pattern. 
> Although not very coherent architecturally, this choice has 
> worked reasonably well.
> 
> Adding a pattern converter to handle the %e specifier should 
> be easy. The only difficulty may arise in returning the 
> correct value in
> ignoresThrowable() for all cases.
> 
> For example, if the pattern is "%m%n%e", then 
> ignoresThrowable() for the PatternLayout should return false, 
> but if the pattern is "%m%n", then ignoresThrowable() should 
> return true. This can be achieved by having each 
> PatternConverter inform the PatternLayout instance of whether 
> it handles exceptions or not.
> 
> Anyway, your question justifies adding a PatternConverter to 
> handle the %e case.
> 
> Hope this helps,
> 
> At 07:12 PM 9/16/2004, you wrote:
> >We are trying to setup some automated alarming when errors 
> are written 
> >to our log files.
> >The problem we are having is that the message span multiple 
> lines, with 
> >no obvious beginning or end to each message.
> >I tried adding literals at the beginning and end of the conversion 
> >pattern, but that didn't work because the exception is written after 
> >the end of the pattern.
> >
> >The best solution I could think of is to support a pattern 
> ("%e"?) for 
> >the exception string in the PatternLayout.
> >If the pattern contains %e, the layout would return false for 
> >IgnoresException, and it would render the exception as part of the 
> >pattern, which would let the end marker come after the exception.
> >If the pattern does contains %e, it would return true for 
> >IgnoresException, and the behavior would be unchanged.
> >
> >Make sense?
> >
> >Has anybody done this?
> >If not, if I do it will somebody commit it?
> >
> >Thanks,
> >         Dave
> 
> --
> Ceki G�lc�
> 
>       For log4j documentation consider "The complete log4j manual"
>       ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  
> 
> 
> 

Reply via email to