LogEntry with custom properties

Topics: Logging Application Block
Oct 24, 2007 at 7:56 PM

From the posts regarding the adding custom fields to LogEntry, I understood that CustomLogEntry class can created extending LogEntry class, add the properties need. Do I need to create custom formatter OR is there a easy way?
Appreciate your help.
Oct 25, 2007 at 3:40 AM
1. Create an custom log entry class extending "LogEntry" class
2. Modified the text formatter template to use the custom property(ies) created in the custom log entry using the following format
CustomTag: {property(CustomPropertyName)}

CustomPropertyName - is a property name in the custom log entry
CustomTag - is the tag that gets printed in the trace

For example, I created custom logentry

Public Class CustomLogEntry: LogEntry
private string m_LoginName;
public string LoginName
get{ return this.m_LoginName; }
set{ this.m_LoginName = value; }

The formatter would be added a template entry like this
Login Name: {property(LoginName)}
Oct 25, 2007 at 4:45 AM

Yes, using the property token is the way to go; it is not necessary to create a custom formatter. Not sure if your second post describes the solution or asks for confirmation though.

Oct 25, 2007 at 5:51 PM
Thanks Fernando for your input. Yes, I showed in my second post at the bottom of the message "Login Name: {property(LoginName)}". I added this line to text formatter template.