Open dzmitry-lahoda opened 4 years ago
I'm not really sure what this means.
Usually the Adapter pattern is used to adapt from one pattern to another. i.e. public class TraceSourceAdapterLogger : ILogger { public TraceSourceAdapterLogger(TraceSource traceSource)...
However, this already exists, TraceSourceLoggerProvider.
If you configure TraceSourceLoggerProvider for a modern app that is using Microsoft.Extensions.Logging ILogger, then it will write through to the trace source (actually a hierarchy of trace sources, based on the name), and then through to any attached listeners, including the listeners from Essential Diagnostics.
However there is no automatic configuration, i.e. it won't load XML property settings, etc. This means you need to wire everything up in code. You can do this at the host level and then inject, or could even use reflection to load dynamically, but would have to do all that yourself.
I would just use ILogger, and I have already ported some of the TraceListeners across to equivalent LoggerProviders in my Essential.Logging project.
Could we have extension method onto
TraceSource
which exactly same asILogger
, but with no dependency onASP.NET
. So kind of reference free drop in replacement.