logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: [Log4net-devel] Log an Exception
Date Wed, 15 Dec 2004 16:08:00 GMT
Mike,

Are you only logging an exception object or are you logging some message
in addition to the exception?

The log4net ILog interface supports methods like:

Debug(object)
Debug(object,Exception)

Are you using the first or second method?
log4net makes a distinction between the message (which is an object) and
the additional exception. Typically a message is logged and may have an
optional exception attached. log4net stores and processes the exception
separately to the message. Note that as the message is an object it may
be an Exception instance, but log4net still treats this as the message
object, not the additional exception data.

The message is rendered using the PatternLayout, the exception is added
to the output if the layout does not render it.
The ExceptionLayout takes the optional exception, not the message, and
rendered that. It is only really used by the AdoNetAppender which uses
multiple layouts.

The PatternLayout's %m pattern renders the message object to a string.
The PatternLayout does not process any additional exception that may
have been specified. If there is an additional exception its ToString
method is called an that is appended to the output of the pattern.

Whether the exception is passed as the message or additional exception
the object is not broken up into component parts - type, message, stack
trace, inner exception. These parts cannot be logged separately using
the built-in Layouts.

Nicko

> -----Original Message-----
> From: log4net-devel-admin@lists.sourceforge.net
> [mailto:log4net-devel-admin@lists.sourceforge.net] On Behalf Of 
> Collier, Mike
> Sent: 13 December 2004 23:42
> To: log4net-users@lists.sourceforge.net;
> log4net-devel@lists.sourceforge.net
> Subject: [Log4net-devel] Log an Exception
> 
> How would I log an exception (type, message, and stack trace) using, 
> for example, the ConsoleAppender or FileAppender?  It seems that the 
> "%m"
> conversion character in PatternLayout prints my log message, and the 
> exception type and message, but not the stack trace.
> I see that the ExceptionLayout prints out the exception information.  
> I don't see a way to use the ExceptionLayout with appenders like the 
> ConsoleAppender.  I could use the ExceptionLayout with the 
> ADONetAppender though.
> 
> Do I need to implement my own conversion character?
> 
> I'm using Log4NET 1.2.0 beta 8.
> 
> 
> Thanks!
> 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide Read honest & candid 
> reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now. 
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Log4net-devel mailing list
> Log4net-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/log4net-devel
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Log4net-devel mailing list
Log4net-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4net-devel


Mime
View raw message