Adding a new category

Topics: Logging Application Block
Aug 4, 2010 at 1:22 AM

I am curious to know how to add a new category. For example if we cretae new event log and source for a new application. To sagregate errors from different tier we want to create category for each tier.

Thanks

Aug 4, 2010 at 2:16 AM

You mean to say add a new logging category at run time? If yes, and you're using EntLib 5.0, check out the Fluent Configuration API.

 

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

Aug 4, 2010 at 2:28 AM

Thanks for your reply.

No. Actually I meant to say creating static category manually and using it while populating logentry object

So e.g. if we already have created a category called "UI Events", I should be able to use it

logEntry.Categories.Add("UI Events")

Also I am curious if this is the correct approach to group events e.g. for each tier - ui, middle and db of an application?

 

 

Aug 4, 2010 at 2:37 AM

Yes, that would be a correct approach although there may be other ways other people are doing it.  But that's the simplest.

So you're asking about how to add a new category using the config tool?

 

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

Aug 4, 2010 at 2:39 AM

Thats correct. The categories will created only once while deployment.

Aug 4, 2010 at 2:46 AM

If you're using version 5.0, open your config file using the entlib config tool and add the logging configuration section by clicking on the Blocks menu and selecting Add Logging Settings.  You'll see the the Categories section of the Logging Settings block which contains the General category by default.  You can add a new one by clicking on the + sign on the top right corner of the Categories section.   You can then add trace listeners to it by adding trace listeners on the Logging Trace Listeners section, expand the category you've just created and click on the + sign on the Listeners property.  Select the trace listener you want to add from the dropdownlist which appears below.

 

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

Aug 4, 2010 at 5:14 AM

Thanks Sarah. That was very helpful.