Class LoggingJobHistoryPlugin
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:
<table>
<tr>
<th>Element</th>
<th>Data Type</th>
<th>Description</th>
</tr>
<tr>
<td>0</td>
<td>String</td>
<td>The Job's Name.</td>
</tr>
<tr>
<td>1</td>
<td>String</td>
<td>The Job's Group.</td>
</tr>
<tr>
<td>2</td>
<td>Date</td>
<td>The current time.</td>
</tr>
<tr>
<td>3</td>
<td>String</td>
<td>The Trigger's name.</td>
</tr>
<tr>
<td>4</td>
<td>String</td>
<td>The Trigger's group.</td>
</tr>
<tr>
<td>5</td>
<td>Date</td>
<td>The scheduled fire time.</td>
</tr>
<tr>
<td>6</td>
<td>Date</td>
<td>The next scheduled fire time.</td>
</tr>
<tr>
<td>7</td>
<td>Integer</td>
<td>The re-fire count from the JobExecutionContext.</td>
</tr>
</table>
The default message text is "Job {1}.{0} fired (by trigger {4}.{3}) at: {2:HH:mm:ss MM/dd/yyyy}"
JobSuccessMessage - available message data are:
<table>
<tr>
<th>Element</th>
<th>Data Type</th>
<th>Description</th>
</tr>
<tr>
<td>0</td>
<td>String</td>
<td>The Job's Name.</td>
</tr>
<tr>
<td>1</td>
<td>String</td>
<td>The Job's Group.</td>
</tr>
<tr>
<td>2</td>
<td>Date</td>
<td>The current time.</td>
</tr>
<tr>
<td>3</td>
<td>String</td>
<td>The Trigger's name.</td>
</tr>
<tr>
<td>4</td>
<td>String</td>
<td>The Trigger's group.</td>
</tr>
<tr>
<td>5</td>
<td>Date</td>
<td>The scheduled fire time.</td>
</tr>
<tr>
<td>6</td>
<td>Date</td>
<td>The next scheduled fire time.</td>
</tr>
<tr>
<td>7</td>
<td>Integer</td>
<td>The re-fire count from the JobExecutionContext.</td>
</tr>
<tr>
<td>8</td>
<td>Object</td>
<td>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 "Job {1}.{0} execution complete at {2:HH:mm:ss MM/dd/yyyy} and reports: {8}"
JobFailedMessage - available message data are:
<table>
<tr>
<th>Element</th>
<th>Data Type</th>
<th>Description</th>
</tr>
<tr>
<td>0</td>
<td>String</td>
<td>The Job's Name.</td>
</tr>
<tr>
<td>1</td>
<td>String</td>
<td>The Job's Group.</td>
</tr>
<tr>
<td>2</td>
<td>Date</td>
<td>The current time.</td>
</tr>
<tr>
<td>3</td>
<td>String</td>
<td>The Trigger's name.</td>
</tr>
<tr>
<td>4</td>
<td>String</td>
<td>The Trigger's group.</td>
</tr>
<tr>
<td>5</td>
<td>Date</td>
<td>The scheduled fire time.</td>
</tr>
<tr>
<td>6</td>
<td>Date</td>
<td>The next scheduled fire time.</td>
</tr>
<tr>
<td>7</td>
<td>Integer</td>
<td>The re-fire count from the JobExecutionContext.</td>
</tr>
<tr>
<td>8</td>
<td>String</td>
<td>The message from the thrown JobExecution Exception.
The default message text is "Job {1}.{0} execution failed at {2:HH:mm:ss MM/dd/yyyy} and reports: {8}"
JobWasVetoedMessage - available message data are:
<table>
<tr>
<th>Element</th>
<th>Data Type</th>
<th>Description</th>
</tr>
<tr>
<td>0</td>
<td>String</td>
<td>The Job's Name.</td>
</tr>
<tr>
<td>1</td>
<td>String</td>
<td>The Job's Group.</td>
</tr>
<tr>
<td>2</td>
<td>Date</td>
<td>The current time.</td>
</tr>
<tr>
<td>3</td>
<td>String</td>
<td>The Trigger's name.</td>
</tr>
<tr>
<td>4</td>
<td>String</td>
<td>The Trigger's group.</td>
</tr>
<tr>
<td>5</td>
<td>Date</td>
<td>The scheduled fire time.</td>
</tr>
<tr>
<td>6</td>
<td>Date</td>
<td>The next scheduled fire time.</td>
</tr>
<tr>
<td>7</td>
<td>Integer</td>
<td>The re-fire count from the JobExecutionContext.</td>
</tr>
</table>
The default message text is "Job {1}.{0} was vetoed. It was to be fired (by trigger {4}.{3}) at: {2:HH:mm:ss MM/dd/yyyy}"
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
loggerILogger<LoggingJobHistoryPlugin>Where the history lines go.
timeProviderTimeProviderThe 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
JobSuccessMessage
Get or sets the message that is logged when a Job successfully completes its execution.
public string JobSuccessMessage { get; }
Property Value
JobToBeFiredMessage
Gets or sets the message that is logged when a Job is about to Execute.
public string JobToBeFiredMessage { get; }
Property Value
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
Name
Get the name of the IJobListener.
public string Name { get; }
Property Value
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
pluginNamestringschedulerISchedulercancellationTokenCancellationToken
Returns
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
contextIJobExecutionContextcancellationTokenCancellationToken
Returns
- 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
contextIJobExecutionContextcancellationTokenCancellationToken
Returns
- 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
contextIJobExecutionContextjobExceptionJobExecutionExceptioncancellationTokenCancellationToken