Logging extra columns

Topics: Logging Application Block
Jan 18, 2007 at 2:30 PM
I'm using the Exception Handling block with the Logging block. I'd like to log extra information, but not within the exception message; I need to be able to write to new columns. Does this require code changes or can it be done from config, maybe with a custom formatter?

Thanks,
Barry
Jan 18, 2007 at 4:38 PM
I don't see a way to do this using the LoggingHandler with the Exception Handling Block without doing some sort of customization.

If you log exceptions using the Logging Application Block directly, however, you can use the LogEntry.ExtendedProperties Property to add extra information easily as Key/Value Pairs.

Regards,

Dave

________________________

David Hayden
Microsoft MVP C#
http://www.davidhayden.com/
Jan 18, 2007 at 5:49 PM
Thanks for your reply. I'm aware of this capability, but want to avoid having to parse the key/value pairs from the message column in my log reader.

Thanks,
Barry
Jan 19, 2007 at 3:07 AM
Not sure if this is what you want, but if you stick extra info into the Exception.Data property, this will get added to the LogEntry's ExtendedProperties collection, which can get accessed by the log formatter.

Tom
Jan 19, 2007 at 3:34 PM
That might help me, but what I'm really after is to be able to redefine the columns in the log table. For example, I'd like to add a user name column and a column indicating whether or not my email notification system should send the record. From what I've seen, the column definitions in the log table are hard-coded. I could derive all sorts of additional information from the formatted message column, but I want to avoid having to parse it.

Would using the XML formatter buy me anything?
Jun 27, 2007 at 12:23 AM
Interesting.... I'm trying to do the same thing. I have data that I would like to include in the Log table by using ex.data.add(), Does anybody know how I go about storing this extra data in a seperate column on the log table?
Jun 27, 2007 at 11:56 AM

gadkins wrote:
Interesting.... I'm trying to do the same thing. I have data that I would like to include in the Log table by using ex.data.add(), Does anybody know how I go about storing this extra data in a seperate column on the log table?


You'll need to modify the Database Trace Listener to pull the data out of the Extended Properties and log it to your specific schema.

Tom
Jun 27, 2007 at 1:20 PM

tomhollander wrote:

gadkins wrote:
Interesting.... I'm trying to do the same thing. I have data that I would like to include in the Log table by using ex.data.add(), Does anybody know how I go about storing this extra data in a seperate column on the log table?


You'll need to modify the Database Trace Listener to pull the data out of the Extended Properties and log it to your specific schema.

Tom


Thanks, I'll look into this.....