Disable Only Exception Log and Enable All Others Logs and Vice Versa

Topics: Exception Handling Application Block, Logging Application Block
Jun 20, 2009 at 10:02 AM

I know we can enable & disable Exception Handling Logs and other Logs simeltanously.

Is there a way that we can only Log Exception Handling but not Log others and/or vice versa

For example, I have this code

// I want to Log this

ExceptionPolicy.HandleException(......);;

//But Not Log this

Logger.Write(.....);

and Vice Versa.

Please Let me know this is possible or not through configuration files.
I don't want to use Filters.

Jun 21, 2009 at 3:28 AM

The solution I was supposed to suggest was to use Filter property of the TraceListeners, but you don't want to use that.  And after a while, I also think that wouldn't cover for all scenarios.  Or are you talking about the global filters?  If this is what you're referring to and don't want to create your own custom filter, I'm afraid there are no other workarounds. 

 

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

 

Jun 22, 2009 at 4:31 AM

Really Thanks for your Reply.

I want a property in config file,like tracingEnabled property

but the problem is this will enable and disable both Exception Handling and tracing simeltanoulsy.

I need enable and disable one.

Is there is no work around except Filters.

 

Jun 22, 2009 at 7:34 AM
Edited Jun 22, 2009 at 7:36 AM

I agree with sarah, I think there is no other work around there except for the filters. do you have a specific reason for not wanting to use filters?

Valiant Dudan
Global Technology & Solutions
Avande, Inc.
entlib.support@avanade.com

Jun 22, 2009 at 9:38 AM

Simply Because It need to implement a new Custom Filter,
Because none of The CategoryFilter, PriorityFilter, and LogEnabledFilter
satisy my needs.

Did you not think there should a property of this in Config or there is a need of this in future.

Because Exception and Logging are two separate blocks.

 

Jun 23, 2009 at 1:32 AM
Edited Jun 23, 2009 at 3:19 AM

Yes, they are 2 separate blocks but still, the Exception block leverages the features of the Logging block.  The latter is not isolated from the other one.   I didn't have a need for this and I'm not usre if a lot of people really need it so I can't say if entlib should support it.   What's your use case for wanting to have this behavior? 

 

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

Jun 23, 2009 at 9:07 AM

Really Thanks for all of your Help,

>> What's your use case for wanting to have this behavior? 

There are Lot of Occasions in which you need,
 to Enable Only One for a certain time of Periods then Disable one again for increasing Performance.
There fore for doing this immediately is possible with Configuration File.

Thanks both Sarah and Valiant for your help.

 

Jun 23, 2009 at 9:49 AM

The closest thing you could get is to set the Filter property of your tracelisteners to Error so it will only log exceptions which are most likely coming from exception handling. But Logger.Write statements writing logs of error type would of course wouldn't be filtered out. 

Anyway, glad to be of help.

 

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