Consolidate Logging Sources

Topics: Logging Application Block
Jul 23, 2007 at 10:26 AM

I've been investigating the Enterprise Library a bit but there is one little nugget that I can't seem to find any info on. Since a least part of the Logging AppBlock is built on the System.Diagnostics stuff I though that it would be possible to consolidate data written to a System.Diagnostics.TraceSource into the LogSources configured for the Logging AppBlock. I was considering a scenario where a third party (or another inhouse team) was developing assemblies to our team instrumented with System.Diagnostics.TraceSource logging and having this logging be incorporated into our EntLib Logging sources (so you would not need seperate log files etc.) but I can't seem to find a way. Is this scenario not supported or is there an elegant (or even less elegant) workaround?

Jul 23, 2007 at 3:15 PM

You could have a TraceListener working as a bridge to the LoggingBlock, similar to the EntLibLoggingProxyTraceListener. Actually the existing trace listener might just work, although it's optimized for bridging Xml from WCF logging. This would only work if your third party is using configuration driven trace sources, and this of course means you'd still have two pieces of configuration.

Here's a snippet of the configuration in the logging unit tests:

<source name="entlibproxy">
<add name="entlibproxy"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EntLibLoggingProxyTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"/>

Hope this helps,