using Categories with Enterprise library logging

Topics: Logging Application Block
Nov 11, 2007 at 10:59 PM
All,
am trying to use the new 3.1 release of the Logging application feature of the Enterprise library.
I would like to use specific categories.
The Categories I define using the Enterprise Library configuration tool (for example "Caching", "Data Access", "General") that are added to the App.config file, are these the same values I should use when I am actually logging.
For example
LogEntry le = new LogEntry("My Message","General", 1,1,System.Diagnostics.TraceEventType.Information, "My Title",null);

How can I easily reference the Categories other than creating a Collection or ENUM type for the Categories?
Is there a way the Categoreies is picked up from the App.config file during design time?

Jawahar
Nov 12, 2007 at 12:01 PM
Hi,

What do you mean by "Is there a way the Categoreies is picked up from the App.config file during design time?"? Where do you want to use the categories at design time?

You can retrieve the raw configuration information from the configuration file, using code like
((LoggingSettings)new FileConfigurationSource([your configuration file]).GetSection(LoggingSettings.SectionName)).TraceSources

That will give you a collection of TraceSourceData with a Name property.

Regards,
Fernando
Nov 16, 2007 at 7:16 PM
This is the worst messageboard software, ever.

I wrote an informative reply that included a link, clicked the link, and now my reply is gone forever.

Too bad. If only MS had a clue.



jawahar wrote:
All,
am trying to use the new 3.1 release of the Logging application feature of the Enterprise library.
I would like to use specific categories.
The Categories I define using the Enterprise Library configuration tool (for example "Caching", "Data Access", "General") that are added to the App.config file, are these the same values I should use when I am actually logging.
For example
LogEntry le = new LogEntry("My Message","General", 1,1,System.Diagnostics.TraceEventType.Information, "My Title",null);

How can I easily reference the Categories other than creating a Collection or ENUM type for the Categories?
Is there a way the Categoreies is picked up from the App.config file during design time?

Jawahar