在我的基于 Quartz.NET 的应用程序中,我有一个 JobListener,用于审核对审核表执行的所有作业。但是,我还希望侦听器能够检测到每当发生任何类型的错误时,这样我就可以捕获此错误并向电子邮件地址发送电子邮件告知存在错误,并且可能会找到特定的错误(即我的程序移动文件,因此错误可能会发生)路径不存在)。
我如何侦听失败的作业,以及是否可以检测是否存在大量错误,并且在这种情况下仅发送几封电子邮件,而不是为每个错误发送一封电子邮件?
In my Quartz.NET based application, I have a JobListener that audits all jobs executed to an audit table. However, I also want a listener to detect whenever any sort of error occurs, so I can catch this and email an email address that there is an error, and maybe find the specific error (i.e. my program moves files around, so an error could be a path doesn't exist).
How do I listen for failed jobs, and also is it possible to detect whether there is a huge number of errors, and in that case only send a few emails rather than an email for every single error?
发布评论
评论(1)
要检测何时发生任何类型的错误,您需要实现一个侦听器,作业侦听器或触发器侦听器,或者可能两者都需要:http://quartznet.sourceforge.net/tutorial/lesson_7.html
您可以通过调用您创建的 IScheduler 对象上的方法来附加侦听器。
我们汇总多封电子邮件的方法是使用日志系统,特别是 NLog。我们在 BufferingWrapper wiki/Mail_target" rel="nofollow">邮件目标,以便在记录一些指定数量的事件(例如 200)后或在最后记录的错误后经过指定的超时期限后发送错误日志(例如,2 分钟)。
To detect whenever any sort of error occurs you will want to implement a listener, either a Job listener or a Trigger listener, or probably you'll want both: http://quartznet.sourceforge.net/tutorial/lesson_7.html
You can attach the listeners by calling methods on the IScheduler object you create.
What we do to roll-up multiple emails is use a logging system, specifically NLog. We use a BufferingWrapper around a Mail target so that the error log is sent after some specified number of events has been logged (e.g., 200) or after a specified timeout period has elapsed after the last logged error (e.g., 2 minutes).