Reduce Logging / Remove Specific Batch acquisition Message with Serilog?

1,162 views
Skip to first unread message

Ian Frawley

unread,
Jun 24, 2020, 4:27:23 AM6/24/20
to Quartz.NET

My .NET Core 3 implementation of Quartz.Net is logging the following message approximately twice per minute and I would like to remove it without affecting my applications other logs:

"Batch acquisition of 0 triggers"

2020-06-22 17:42:24.745 +01:00 - [MyApplication] - [Debug] - [Quartz.Core.QuartzSchedulerThread] Batch acquisition of 0 triggers
2020-06-22 17:42:53.689 +01:00 - [MyApplication] - [Debug] - [Quartz.Core.QuartzSchedulerThread] Batch acquisition of 0 triggers

Where [MyApplication] is populated by the Source property and [Quartz.Core.QuartzSchedulerThread] comes from the SourceContext.

Quartz.net logs this automatically and I seem to have no control over deciding to log it or not. My logs are filling up too quickly.

My Appsettings.json file is as follows:

"Serilog": {
"IncludeScopes": false,
"MinimumLevel": {
  "Default": "Debug",
  "Override": {
    "Microsoft": "Warning",
    "System": "Warning"
  }
},
"WriteTo": [
  {
    "Name": "File",
    "Args": {
      "path": "C:/Logs/my-app.log",
      "buffered": "true",
      "flushToDiskInterval": "00:00:10",
      "rollingInterval": "Infinite",
      "rollOnFileSizeLimit": "true",
      "fileSizeLimitBytes": 10485760,
      "retainedFileCountLimit": 90,
      "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} - {Source} - [{Level}] - [{SourceContext}] {Message}{NewLine}{Exception}"
    }
  },
  {
    "Name": "Async",
    "Args": {
      "restrictedToMinimumLevel": "Information",
      "configure": [
        {
          "Name": "Console",
          "Args": {
            "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} - {Source} - [{Level}] - {Message}{NewLine}{Exception}"
          }
        }
      ]
    }
  }
]

}

My Program.cs main initially configures the logger like this:

Log.Logger = new LoggerConfiguration()
            .ReadFrom.Configuration(configuration)
            .Enrich.FromLogContext()
            // set Source property, which we use in output formatting, to the name of the application
            .Enrich.WithProperty("Source", value: "MyApplication")
            .CreateLogger();

And later in my Startup.cs, when my services & settings have been registered Serilog is reconfigured as follows:

 public void Configure(IApplicationLifetime applicationLifetime)
    {
        SerilogLogger.Reconfigure(
            applicationName: "MyApplication",
            toFixedFile: !string.IsNullOrEmpty(_loggerSettings.LogFilePathFixed),
            fileName: _loggerSettings.LogFilePathFixed,
            fileSizeBytes: configuredLogFileSize * 1024 * 1024,
            minimalLevel: "Debug",
            outputTemplate: _loggerSettings.LogFormat);
    }

Where the Reconfigure extension method comes from a 3rd party dll built in another development department.

I have tried to add the following after the invocation of Reconfigure:

SerilogLogger.RefineConfiguration(x => x.MinimumLevel.Override("Quartz", LogEventLevel.Warning));

But it doesn't work because the actual source is MyApplication, and if I use "MyApplication" instead of "Quartz" I suppress all debug and information logs for the entire application.

Any ideas? With code examples please.

Marko Lahma

unread,
Jun 24, 2020, 4:36:45 AM6/24/20
to Quartz. NET

I'm not a Serilog expert, but in general I would suggest you set MinimumLevel::Override::Quartz to "Information" or "Warning". The Debug mode is only for figuring out problems.

The question is more about Serilog / your custom setup than Quartz I believe.

-Marko

--
You received this message because you are subscribed to the Google Groups "Quartz.NET" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quartznet+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quartznet/7dab90ab-f434-4773-ac08-790d37f0b50do%40googlegroups.com.

Ian Frawley

unread,
Jun 24, 2020, 4:43:14 AM6/24/20
to Quartz.NET
Can you tell me where I would set MinimumLevel::Override::Quartz please?

As you can see in my original post I mentioned that setting the following does not work for me because the source is "MyApplication":

SerilogLogger.RefineConfiguration(x => x.MinimumLevel.Override("Quartz", LogEventLevel.Warning));

So, if there is another way to set this, or you mean a different approach i would appreciate if you can give a quick code example?

Thanks for the reply Marko, very much appreciated.

Ian

To unsubscribe from this group and stop receiving emails from it, send an email to quar...@googlegroups.com.

Marko Lahma

unread,
Jun 24, 2020, 4:46:03 AM6/24/20
to Quartz. NET
"MinimumLevel": {
  "Default": "Debug",
  "Override": {
    "Microsoft": "Warning",
    "System": "Warning",
    "Quartz": "Warning"
  }
},

To unsubscribe from this group and stop receiving emails from it, send an email to quartznet+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quartznet/6ab0ae72-5b72-4713-925b-b2273d022d78o%40googlegroups.com.

Ian Frawley

unread,
Jun 25, 2020, 11:03:26 AM6/25/20
to Quartz.NET
Thanks Marko, this worked. Very much appreciated.

I should add that i had to fix other issues of my own doing before this worked. I had to remove the SerilogLogger.Reconfigure code among other things, there was no need for this and it was undermining my Serilog settings in appsettings.json.
Reply all
Reply to author
Forward
0 new messages