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:
| 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
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