We're currently using Autofac and are leveraging the AutofacSerilogIntegration to automatically set up the logging context when an ILogger is injected into a concrete. The integration sets up the logging context with the type the logger is being injected into. This isn't unreasonably hard in Autofac because there is a "Preparing" event that is available for any resolution...so the resolution of the ILogger can be intercepted and the ILogger can be enhanced at that point and Autofac allows the containing type to be ascertained from this interceptor. Here is the code: https://github.com/nblumhardt/autofac-serilog-integration/blob/master/src/AutofacSerilogIntegration/ContextualLoggingModule.cs
I've seen the availability of interception in DryIoc, but nothing as simple as the Autofac approach. In DryIoc it looks like the interceptor has to be registered for each concrete that is injected with the type to be is intercepted. https://bitbucket.org/dadhi/dryioc/wiki/Decorators#markdown-header-decorator-as-interceptor-with-castle-dynamicproxy
Does anybody have advice on the best way to approach this issue in DryIoc? Is this possible in a way that is relatively general and performant? After looking at the DryIoc documentation, I don't see a straightforward approach to this because I don't see a place where the class that is being injected into can be determined in some kind of generalized interceptor (and which can be globally applied). I obviously don't want to examine the call stack from my logger as this is known to be very slow.
Thanks
If Serilog needs the info about the logged Type similar to log4net, then here is the docs with example.