Topics: Logging Application Block
Jan 11, 2007 at 7:21 PM

I am desperatly looking on the internet for an example about logging in the database.
I found one little example (even in the hand-on labs there is no example).
But I receive an error if I am using a category (not de default one). Do I have to specify the new categorie in the config file?

Also I want to use extended fields when I log the information in the database. But I have no clue how to start with this.

Every help, link or tip would be a great help to me.

Jan 12, 2007 at 3:00 PM
Is short yes you need to set up your category and then add a database trace listener to that category using the config tool.
As for the extended properties that is up to you how you want to populate them but it could be something like this:

KeyValuePair<string,object> pair = new KeyValuePair<string,object>();
pair.Key = "Key";
pair.Value = "Value";

LogEntry logEntry = new LogEntry();
logEntry.EventId = 100;
logEntry.Priority = 2;
logEntry.Message = "Informational message";
logEntry.Categories.Add("UI Events");

Jan 12, 2007 at 4:48 PM
Also here are some links:

Hope this helps.
Jan 13, 2007 at 9:04 AM
Thanks a lot, it was for me a great help.

But I had to change the code in :
KeyValuePair<string, object> pair = new KeyValuePair<string, object>();
pair = new KeyValuePair<string, object>("Hello", "World");

Because the pair.value and pair.key are read-only.