If Enterprise Library Logger.Write(logEntry) can properly set Category information

Nov 4, 2009 at 8:03 PM
Edited Nov 5, 2009 at 2:10 PM

I am using Enterprise Library Logger.Write(logEntry) method to log into Windows Event Log. I saw LogEntry constructor takes a parameter named 'Categories'. Is this category corresponding to the category column shown in Event Viewer? If not, which parameter is used for passing values for the Event Viewer Category column.

From what I have seen so far it looks nterprise Library Logger.Write(logEntry) cannot add a record into Event Viewer with desired Category value. Any idea?

Nov 5, 2009 at 5:33 AM

Hi,

I'm just wondering, The overload for the EventLog.WriteEntry(http://msdn.microsoft.com/en-us/library/ysx54zda.aspx) that takes the parameter named 'category' is type of short. Just wonder how did you passed the value 'My Category' which i think is a string type. I tried passing a short value - say 1, at the event log it appears that there is a associated category for the value that I passed.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 5, 2009 at 1:54 PM
Edited Nov 5, 2009 at 1:54 PM
AvanadeSupport wrote:

Hi,

I'm just wondering, The overload for the EventLog.WriteEntry(http://msdn.microsoft.com/en-us/library/ysx54zda.aspx) that takes the parameter named 'category' is type of short. Just wonder how did you passed the value 'My Category' which i think is a string type. I tried passing a short value - say 1, at the event log it appears that there is a associated category for the value that I passed.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Sorry, my bad! I have made the correction for my question.

Nov 6, 2009 at 2:31 AM

Populating the Category column is not supported in the out-of-the-box formatted eventlog trace listener.  You would need to create your custom trace listener.

BTW, I also tried writing to the EventLog.WriteEntry passing a value to the short category parameter and yes, seems like there are already corresponding string values for some numbers(I only tried 0,1 and 2 - 0 means None). 

 

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