I am implementing use of the Logging application block. I was hesitant to scatter code like this all over my app:
So I created an interface ILogWriter:
void WriteDebugInfo(string message);
void WriteGeneralInfo(string message);
Then I created 2 global classes that implement my ILogWriter interface:
LogWriterEnterpriseLibrary - uses unity to populate a private Enterprise Library LogWriter and wraps the creation of LogEntry objects for me
LogWriterNullLogger - implements interface with empty methods (so using this class would effectively disable all logging and remove dependency on Logging Application block)
Q1 - Is using the LogWriterNullLogger idea a good one, to improve performance, or just in terms of general architecture?
Looking at the TraceManager:
The examples have me doing this everywhere in the code:
Q1 - how would I disable or turn off the TraceManager? just use a CategoryFilter for the PerformanceTracing category?
Q2 - is there any performance overhead with this method?
Q3 - Would I be better off trying to implement my own global accessor to the TraceManager and use a similar idea to the LogWriter so that it could be completely removed when turned off?
If you dont want to scatter your code across, you can try using the PIAB with the Logging Application Block using the LoggingCallHandler. If you want to turn off logging, you can add a LogEnabledFilter to the filters node and set the Enabled property to false.
For your performance question, here are related posts:
Global Technology and Solutions
I haven't investigated the PIAB yet. I guess I have to do that. I figured the PIAB was a bit like Unity on steroids, and we are already using Unity to inject the LogWriterEnterpriseLibrary class or the LogWriterNullLogger class, depending on