Stacktrace or FormattedMessage

Topics: Exception Handling Application Block
Feb 18, 2010 at 7:39 AM

I have

Private log As LogEntry

1)I would like to log the stack trace  of an exception.

i cant find log.Stacktrace

2)If i would like to fill the FormattedMessage column of the table Log

which property of  LogEntry shold i set?

 

 

 

http://screencast.com/t/NzNiMTdmNzkt

 

Feb 18, 2010 at 7:59 AM

There isn't a StackTrace property in the LogEntry class.  Here's what you can do:

There is an overload of the Write method which allows you to pass an IDictionary<string, object>.  If you want the stack trace to be included, create a Dictionary<string, object> and add a corresponding entry in there for the stack trace, e.g.

IDictionary<string, object> properties = new Dictionary<string, object>();

properties.Add("stackTrace", ex.StackTrace);

or, you can add those dictionary entries in LogEntry.ExtendedProperties collection properties. 

In your Formatter's Template property, you can then display it by using this token: {keyValue(stackTrace)} - where stackTrace is the key you used in the dictionary.

On your second question, the value of the FormattedMessage column is the end result of how your selected formatter formats the Message property of the LogEntry.  You need to change your formatter's Template property if you want to change the formatting; to change the actual text, you need to change the Message property

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com