Open jruizaranguren opened 7 years ago
The problem is generated by LibLog library. It can be circumvented at least in two different ways:
ILogProvider
and set it through LogProvider.SetCurrentLogProvider(customLogProvider)
You are correct, Metrics.NET uses LibLog to provide logging capabilities, which tries to load supported logging frameworks automatically through reflection. The workarounds you mentioned should work, but aren't ideal.
Looking throught the LibLog code, I noticed that each logger provider implementation has a ProviderIsAvailableOverride
property, which, if set to false, should disable the particular provider. Unfortunately, it seems that the specific ILogProvider
implementations (e.g. EntLibLogProvider
) are marked as internal
, so you can't set this property in your project.
Making the providers public and allowing Metrics.NET users to disable unwanted providers seems like a better alternative then the workarounds you mentioned (at first glance anyways), but I have to look a bit more at the code to see if making them public wouldn't have any undesired side-effects.
I'm trying to enable Metrics.Net 0.4.4 in a web project using Nancy 1.4.3. I'm using the following activation code in ApplicationStartup method:
I have a reference to Enterprise Library logging dll's (4.0.0) because a third party library makes use of them. I'm not using them directly and I do not have any configuration of those libraries in my web.config.
When I launch the web service I'm getting a
System.TypeInitializationException
exception. It seems Metrics.Net is trying to load the EntLib logger:How could I prevent Metrics.Net trying to load EntLib? Is it possible to decide which logger I would like to use?
Thanks.