Class LoggingTriggerHistoryPlugin
Logs a history of all trigger firings.
public sealed class LoggingTriggerHistoryPlugin : ISchedulerPlugin, ITriggerListener
- Inheritance
-
LoggingTriggerHistoryPlugin
- 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, params object[]).
<p>
TriggerFiredMessage - available message data are:
| Element | Data Type | Description |
|---|---|---|
| 0 | String | The Trigger's Name. |
| 1 | String | The Trigger's Group. |
| 2 | Date | The scheduled fire time. |
| 3 | Date | The next scheduled fire time. |
| 4 | Date | The actual fire time. |
| 5 | String | The Job's name. |
| 6 | String | The Job's group. |
| 7 | Integer | The re-fire count from the JobExecutionContext. |
The default message text is <i>"Trigger {1}.{0} fired job {6}.{5} at: {4,
date, HH:mm:ss MM/dd/yyyy}"</i>
</p>
<p>
TriggerMisfiredMessage - available message data are:
| Element | Data Type | Description |
|---|---|---|
| 0 | String | The Trigger's Name. |
| 1 | String | The Trigger's Group. |
| 2 | Date | The scheduled fire time. |
| 3 | Date | The next scheduled fire time. |
| 4 | Date | The actual fire time. (the time the misfire was detected/handled) |
| 5 | String | The Job's name. |
| 6 | String | The Job's group. |
The default message text is <i>"Trigger {1}.{0} misfired job {6}.{5} at:
{4, date, HH:mm:ss MM/dd/yyyy}. Should have fired at: {3, date, HH:mm:ss
MM/dd/yyyy}"</i>
</p>
<p>
TriggerCompleteMessage - available message data are:
| Element | Data Type | Description |
|---|---|---|
| 0 | String | The Trigger's Name. |
| 1 | String | The Trigger's Group. |
| 2 | Date | The scheduled fire time. |
| 3 | Date | The next scheduled fire time. |
| 4 | Date | The job completion time. |
| 5 | String | The Job's name. |
| 6 | String | The Job's group. |
| 7 | Integer | The re-fire count from the JobExecutionContext. |
| 8 | Integer | The trigger's resulting instruction code. |
| 9 | String | A human-readable translation of the trigger's resulting instruction code. |
The default message text is <i>"Trigger {1}.{0} completed firing job
{6}.{5} at {4, date, HH:mm:ss MM/dd/yyyy} with resulting trigger instruction
code: {9}"</i>
</p>
Constructors
LoggingTriggerHistoryPlugin()
Initializes a new instance of the LoggingTriggerHistoryPlugin class.
public LoggingTriggerHistoryPlugin()
LoggingTriggerHistoryPlugin(ILogger<LoggingTriggerHistoryPlugin>, TimeProvider)
Initializes a new instance of the LoggingTriggerHistoryPlugin class.
public LoggingTriggerHistoryPlugin(ILogger<LoggingTriggerHistoryPlugin> logger, TimeProvider timeProvider)
Parameters
loggerILogger<LoggingTriggerHistoryPlugin>timeProviderTimeProvider
Properties
Name
Get the name of the ITriggerListener.
public string Name { get; }
Property Value
TriggerCompleteMessage
Get or set the message that is printed upon the completion of a trigger's firing.
public string TriggerCompleteMessage { get; }
Property Value
TriggerFiredMessage
Get or set the message that is printed upon a trigger's firing.
public string TriggerFiredMessage { get; }
Property Value
TriggerMisfiredMessage
Get or set the message that is printed upon a trigger's mis-firing.
public string TriggerMisfiredMessage { 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
TriggerComplete(ITrigger, IJobExecutionContext, SchedulerInstruction, CancellationToken)
Called by the IScheduler when a ITrigger has fired, it's associated IJobDetail has been executed, and it's Triggered(ICalendar?) method has been called.
public ValueTask TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode, CancellationToken cancellationToken = default)
Parameters
triggerITriggerThe ITrigger that was fired.
contextIJobExecutionContextThe IJobExecutionContext that was passed to the IJob's Execute(IJobExecutionContext, CancellationToken) method.
triggerInstructionCodeSchedulerInstructionThe result of the call on the IOperableTrigger's Triggered(ICalendar?) method.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
TriggerFired(ITrigger, IJobExecutionContext, CancellationToken)
Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.
It is called before the VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken) method of this interface.
public ValueTask TriggerFired(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
Parameters
triggerITriggerThe ITrigger that has fired.
contextIJobExecutionContextThe IJobExecutionContext that will be passed to the IJob's Execute(IJobExecutionContext, CancellationToken) method.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
TriggerMisfired(ITrigger, IScheduler, CancellationToken)
Called by the IScheduler when a ITrigger has misfired.
Consideration should be given to how much time is spent in this method, as it will affect all triggers that are misfiring. If you have lots of triggers misfiring at once, it could be an issue it this method does a lot.
public ValueTask TriggerMisfired(ITrigger trigger, IScheduler scheduler, CancellationToken cancellationToken = default)
Parameters
triggerITriggerThe ITrigger that has misfired.
schedulerISchedulerThe scheduler raising the notification.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken)
Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.
It is called after the TriggerFired(ITrigger, IJobExecutionContext, CancellationToken) method of this interface.
public ValueTask<bool> VetoJobExecution(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
Parameters
triggerITriggerThe ITrigger that has fired.
contextIJobExecutionContextThe IJobExecutionContext that will be passed to the IJob's Execute(IJobExecutionContext, CancellationToken) method.
cancellationTokenCancellationTokenThe cancellation instruction.