How can I lower the frequence of hangfire logs or disable them in .net core?

logging
aspnetcore
dotnetcore
Tags: #<Tag:0x00007fa53ba7f138> #<Tag:0x00007fa53ba7eff8> #<Tag:0x00007fa53ba7eeb8>

#1

My logs are permanently getting spammed with db record logs, so much so I cant even see any real log msgs from my application. I’m using Hangfire and .net core. I’ve set the logging level to different settings but nothing works to stop the crazy amount of flowing logs…

Log snippet:

dbug: Hangfire.MySql.Core.ExpirationManager[0]
      removed records count=-1
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      delete from `AggregatedCounter` where ExpireAt < @now limit @count;
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      removed records count=-1
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      delete from `AggregatedCounter` where ExpireAt < @now limit @count;
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      removed records count=-1
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      delete from `AggregatedCounter` where ExpireAt < @now limit @count;
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      removed records count=-1
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      delete from `AggregatedCounter` where ExpireAt < @now limit @count;
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      removed records count=-1
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      delete from `AggregatedCounter` where ExpireAt < @now limit @count;
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      removed records count=-1
dbug: Hangfire.MySql.Core.ExpirationManager[0]
      delete from `AggregatedCounter` where ExpireAt < @now limit @count;
dbug: Hangfire.MySql.Core.ExpirationManager[0]

In Startup:

 app.UseHangfireServer();
            app.UseHangfireDashboard();

            app.Map("/error", x => x.Run(y => throw new Exception()));
            loggerFactory.AddProvider(new ConsoleLoggerProvider((category, logLevel) => logLevel >= LogLevel.Critical, false));
            loggerFactory.AddConsole();

            this._logger = loggerFactory.CreateLogger<ConsoleLogger>();

Thanks _/_


#2

Check your appsettings.json file(s) for logging levels.

Sounds like your “Logging” section may look like the following:

“Logging”: {
“IncludeScopes”: false,
“LogLevel”: {
“Default”: “Debug”,
“System”: “Information”,
“Microsoft”: “Information”
}
}

If you add a “hangfire” filter (or you can change the “Default” option, it should remove those entries.

“Logging”: {
“IncludeScopes”: false,
“LogLevel”: {
“Default”: “Debug”,
“System”: “Information”,
“Microsoft”: “Information”,
"Hangfire": "Warning"
}
}