Table of Contents

Class LoggingJobHistoryPlugin

Namespace
Quartz.Plugins.History
Assembly
Quartz.Plugins.dll

Logs a history of all job executions (and execution vetoes).

public sealed class LoggingJobHistoryPlugin : ISchedulerPlugin, IJobListener
Inheritance
LoggingJobHistoryPlugin
Implements
Inherited Members

Remarks

The logged message is customizable by setting one of the following message properties to a string that conforms to the syntax of Format(string, object).

JobToBeFiredMessage - available message data are:

Element Data Type Description
0 String The Job's Name.
1 String The Job's Group.
2 Date The current time.
3 String The Trigger's name.
4 String The Trigger's group.
5 Date The scheduled fire time.
6 Date The next scheduled fire time.
7 Integer The re-fire count from the JobExecutionContext.
The default message text is <i>"Job {1}.{0} fired (by trigger {4}.{3}) at: {2:HH:mm:ss MM/dd/yyyy}"</i>
	</p>
	<p>
JobSuccessMessage - available message data are: 
Element Data Type Description
0 String The Job's Name.
1 String The Job's Group.
2 Date The current time.
3 String The Trigger's name.
4 String The Trigger's group.
5 Date The scheduled fire time.
6 Date The next scheduled fire time.
7 Integer The re-fire count from the JobExecutionContext.
8 Object The string value (toString() having been called) of the result (if any) that the Job set on the JobExecutionContext, with on it. "NULL" if no result was set.
The default message text is <i>"Job {1}.{0} execution complete at {2:HH:mm:ss MM/dd/yyyy} and reports: {8}"</i>
	</p>
	<p>
JobFailedMessage - available message data are: 
Element Data Type Description
0 String The Job's Name.
1 String The Job's Group.
2 Date The current time.
3 String The Trigger's name.
4 String The Trigger's group.
5 Date The scheduled fire time.
6 Date The next scheduled fire time.
7 Integer The re-fire count from the JobExecutionContext.
8 String The message from the thrown JobExecution Exception.
The default message text is <i>"Job {1}.{0} execution failed at {2:HH:mm:ss MM/dd/yyyy} and reports: {8}"</i>
	</p>
	<p>
JobWasVetoedMessage - available message data are: 
Element Data Type Description
0 String The Job's Name.
1 String The Job's Group.
2 Date The current time.
3 String The Trigger's name.
4 String The Trigger's group.
5 Date The scheduled fire time.
6 Date The next scheduled fire time.
7 Integer The re-fire count from the JobExecutionContext.
The default message text is <i>"Job {1}.{0} was vetoed.  It was to be fired
(by trigger {4}.{3}) at: {2:HH:mm:ss MM/dd/yyyy}"</i>
	</p>

Constructors

LoggingJobHistoryPlugin()

Creates the plugin with the static logger and the system clock, for a plugin the loader built from a quartz.plugin.<name>.type key and so had nothing to inject into.

public LoggingJobHistoryPlugin()

LoggingJobHistoryPlugin(ILogger<LoggingJobHistoryPlugin>, TimeProvider)

Creates the plugin with the logger and clock a container resolved, which is what UseJobHistoryLogging uses.

public LoggingJobHistoryPlugin(ILogger<LoggingJobHistoryPlugin> logger, TimeProvider timeProvider)

Parameters

logger ILogger<LoggingJobHistoryPlugin>

Where the history lines go.

timeProvider TimeProvider

The clock the lines are stamped with.

Properties

JobFailedMessage

Get or sets the message that is logged when a Job fails its execution.

public string JobFailedMessage { get; }

Property Value

string

JobSuccessMessage

Get or sets the message that is logged when a Job successfully completes its execution.

public string JobSuccessMessage { get; }

Property Value

string

JobToBeFiredMessage

Gets or sets the message that is logged when a Job is about to Execute.

public string JobToBeFiredMessage { get; }

Property Value

string

JobWasVetoedMessage

Gets or sets the message that is logged when a Job execution is vetoed by a trigger listener.

public string JobWasVetoedMessage { get; }

Property Value

string

Name

Get the name of the IJobListener.

public string Name { get; }

Property Value

string

Methods

Initialize(string, IScheduler, CancellationToken)

Called during creation of the IScheduler in order to give the ISchedulerPlugin a chance to Initialize.

public ValueTask Initialize(string pluginName, IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

pluginName string
scheduler IScheduler
cancellationToken CancellationToken

Returns

ValueTask

JobExecutionVetoed(IJobExecutionContext, CancellationToken)

Called by the IScheduler when a IJobDetail was about to be executed (an associated ITrigger has occurred), but a ITriggerListener vetoed it's execution.

public ValueTask JobExecutionVetoed(IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

context IJobExecutionContext
cancellationToken CancellationToken

Returns

ValueTask
See Also

JobToBeExecuted(IJobExecutionContext, CancellationToken)

Called by the IScheduler when a IJobDetail is about to be executed (an associated ITrigger has occurred).

This method will not be invoked if the execution of the Job was vetoed by a ITriggerListener.

public ValueTask JobToBeExecuted(IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

context IJobExecutionContext
cancellationToken CancellationToken

Returns

ValueTask
See Also

JobWasExecuted(IJobExecutionContext, JobExecutionException?, CancellationToken)

Called by the IScheduler after a IJobDetail has been executed, and be for the associated ITrigger's Triggered(ICalendar?) method has been called.

public ValueTask JobWasExecuted(IJobExecutionContext context, JobExecutionException? jobException, CancellationToken cancellationToken = default)

Parameters

context IJobExecutionContext
jobException JobExecutionException
cancellationToken CancellationToken

Returns

ValueTask