Logging with only one category

Topics: Logging Application Block
Sep 7, 2009 at 1:26 AM

Hi,

I have a scenario:

I want to log Errors and critical(only) to a flat file, Information (only) to the event log and other levels to the database. But I want to do this with only one category preferably my default logging category. Is it possible?

Sep 7, 2009 at 3:46 AM
Edited Sep 7, 2009 at 3:47 AM

Hi,

You can create a single category and add the different tracelisteners. Try to set the "Filter" property of the of the trace listener to the level that you want the trace listener to log.

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

Sep 24, 2009 at 9:09 PM
AvanadeSupport wrote:

Hi,

You can create a single category and add the different tracelisteners. Try to set the "Filter" property of the of the trace listener to the level that you want the trace listener to log.

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

according to your post: i have 3 threads. every one calls the same category (email_exception), but with a different severity (error, critical, warning). the category has 3 trace listeners (email_critical,email_warning,email_error). unfortunately if i write a log entry with the severity 'critical' there is not just executed the trace listener with the listener-filter 'critical' but also the one with 'error'.

maybe there is an inheritance hierarchy?

 

 

 

 

 

Sep 25, 2009 at 2:03 AM

Yes, the Filter property actually works that way.  Setting it to Warning will cause it to detect warnings, errors, and critical events.  The SourceLevels property is actually the one you need but you would have to create 3 categories.

 

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

Sep 25, 2009 at 8:21 AM
AvanadeSupport wrote:

Yes, the Filter property actually works that way.  Setting it to Warning will cause it to detect warnings, errors, and critical events.  The SourceLevels property is actually the one you need but you would have to create 3 categories.

 

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

okay, is there anywhere a short tutorial about filter inheritance hierarchy?

 

 

Sep 25, 2009 at 8:55 AM

You can just Go To Definition of the TraceEventType enumeration and you can see the hierarchy based on the number equivalent to each.

 

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