Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz.NET stops triggering after random durations

I have Quartz.NET scheduler (inside a Windows service) running every 15 minute using a cron expression as 0 0/15 * * * ?.

It runs well for a random amount of time, usually more than 2 days and not more than 5 days.

My log4net logger is configured to append a line every time the scheduler is triggered and that is how I will know it has stopped.

I have checked Windows event viewer for any unhandled exception and found nothing. Is there any way with Quartz.net to find out what's going wrong inside?

like image 505
Babu James Avatar asked Feb 06 '26 14:02

Babu James


1 Answers

I have a similar scenario that runs without issues for months so I have no idea what goes wrong in your scenario. However, Quartz.NET uses Common Logging that I have configured in my application so I can give you my relevant configuration sections so you can configure logging for Quartz.NET.

First: the required config sections:

<configSections>
  <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  <sectionGroup name="common">
    <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
  </sectionGroup>
  <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  ...
</configSections>

Second: my Quartz.NET configuration. My job store is SQL Server.

<quartz>
  <add key="quartz.scheduler.instanceName" value="QuartzScheduler" />
  <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
  <add key="quartz.threadPool.threadCount" value="3" />
  <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
  <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
  <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
  <add key="quartz.jobStore.useProperties" value="true" />
  <add key="quartz.jobStore.dataSource" value="myDS" />
  <add key="quartz.dataSource.myDS.connectionString" value="Data Source=.;Initial Catalog=Development;Integrated Security=True" />
  <add key="quartz.dataSource.myDS.provider" value="SqlServer-20" />
</quartz>

And finally the logging configuration:

<common>
  <logging>
    <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net">
      <arg key="configType" value="INLINE" />
    </factoryAdapter>
  </logging>
</common>
<log4net>
  <appender name="RootAppender" type="log4net.Appender.RollingFileAppender">
    <file value="C:\Log\Service.log" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value=" dd-MM-yyyy" />
    <maxSizeRollBackups value="30" />
    <filter type="log4net.Filter.LevelRangeFilter">
      <param name="LevelMin" value="All" />
    </filter>
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d{dd-MM-yyyy HH:mm:ss,fff} %-5level %property{UsnSearchKey} (%logger) %message%newline%exception" />
    </layout>
  </appender>
  <root>
    <appender-ref ref="RootAppender" />
  </root>
  <!-- Specify minimum logging level for Quartz logger. -->
  <logger name="Quartz">
    <level value="DEBUG" />
  </logger>
</log4net>

This configuration should create a Service.log file inside a c:\Log directory that has the debug log statements for Quartz.NET.

like image 77
Ronald Wildenberg Avatar answered Feb 09 '26 09:02

Ronald Wildenberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!