Job logs

The engine uses Serilog Serilog.AspNetCore package for logging through standard .NET logging.

Make sure to configure .NET to use Serilog like this:

builder.Host.UseSerilog((context, services, configuration) =>

And your appSettings.json should include:

"Serilog": {
  "Using": ["CommerceMind.Nexus.Jobs"],
  "WriteTo": [{ "Name": "NexusJobLogs" }]

More info here:

Included in Nexus is a special Serilog log sink that captures all logs that occur during the execution of a job. Both logs from inside the IScheduledJob.ExecuteAsync() method and any logs happening inside other classes called by the job are captured as part of that job run.


Collected job logs are continuously flushed to the IJobLogWriter by the job executor as they occur.

There's two implementations of this interface built in. One for Postgres, one for SQL Server and one for SQLite and whichever database you've chosen to store job meta data is also used for logs. Logging to the database is enabled by default, but you can turn it off like this:

builder.Services.AddNexusScheduledJobs(options =>
    options.SaveLogsToDatabase = false;

Job logs are then stored in the database for as long as you'e set the retention for historical runs. When a historical run is deleted the logs for that run is also deleted.

The default is to store historical runs and logs forever, but you can configure it like this:

builder.Services.AddNexusScheduledJobs(options =>
    options.HistoricalRunsRetention = TimeSpan.FromDays(10);


When requesting job logs for a specific run the IJobLogProvider service is called. The built in implementations that stores logs in the database also implement this interface. When calling AddNexusScheduledJobs() like the example above both the writer and the provider gets registered.

If you send your logs to an external source like Elastic Search or Application Insights you can provide your own implementation of this interface.


You can view the job logs in the admin UI where all logs for a single job run are displayed to make troubleshooting a job easier