I’ve been trying to get hangfire to log to elmah correctly. I’m sure it used to work, but it seemed to stop, when it stopped I don’t know.
We have log4net installed in the same project, and that receives all the logging events just fine (which seems to be hooked up based on the auto reflection stuff described in the logging section of the documentation)
However elmah seems to miss out. ApplicationName is still set, I know that is important when not being stored against an httpcontext. So I’m not sure where to go?
I tried to create my own logging provider, however all messages passed through just come through with: WARN, null messageFunc and null exception.
Is there something I’m missing? Without indepth knowledge of the code, it feels like only one of the logging providers can be setup, and the auto log4net stuff is overriding anything else setup after it.
We are using the latest stable version 1.6.14.
I’ve tried to set the logger directly using the following code, however it still outputs to log4net:
If I request the log provider, with code similar to this, and then log an Error it works. But not when allowing Hangfire to do it itself internally.
ILog Logger = LogProvider.For<AutomaticRetryAttribute>();
Previously I had the setup doing the following, however I started using the above syntax when looking through the source and seeing how the loggers were setup.
GlobalConfiguration.Configuration .UseSqlServerStorage("DefaultConnection") .UseElmahLogProvider(LogLevel.Warn) .UseActivator(containerActivator);