Is there a way to turn off logging that Hangfire does with serilog?
Define a logger and log provider that does not log anything:
using Hangfire;
using Hangfire.Logging;
public class NoLoggingProvider : ILogProvider {
public ILog GetLogger(string name) {
return new NoLoggingLogger();
}
}
public class NoLoggingLogger : ILog {
public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception = null) {
return false;
}
}
and configure Hangfire to use it in your Startup
class:
using Hangfire;
public class Startup {
public void Configuration(IAppBuilder app) {
GlobalConfiguration.Configuration.UseLogProvider(new NoLoggingProvider());
// the rest of your configuration...
}
}