Getting the Castle Windsor Quartz.Net Facility logging with your log4net configuration

The Castle Windsor Quartz.Net facility is pretty awesome, it making getting Quartz.net up and running a fairly painless process.  However, when things go wrong, Quartz.net will be SILENT about it, unless you configure logging correctly.  Already having log4net and Castle.Facilities.Logging setup in my project, here’s the awesomeness that my team came up with to get Quartz.net to tell us what’s up:

Step number the 1) Add a reference to Common.Logging v2.0.0.0 and Common.Logging.Log4Net v2.0.0.0

Step number the 2) Add this assembly binding redirect to your app/web.config:


<dependentAssembly>

<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral"/>

<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="2.0.0.0"/>

</dependentAssembly>

Step number the 3)  Add this section group to the <configSections> in your app/web.config:

</pre>
<sectionGroup name="common">

<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />

</sectionGroup>
<pre>

Step number the 4) Add this xml block in the <configuration> block, right after <configSections> works good:

</pre>
<common>

<logging>

<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net">

<arg key="configType" value="FILE-WATCH" />

<arg key="configFile" value="Log4Net.config" />

</factoryAdapter>

</logging>

</common>
<pre>

Step number the last) Profit.

Now, if you mess up your cron schedule, like

<cron-expression>15 0/1 * CAT * ?</cron-expression>

, you’ll get a beautiful error:


<pre>ERROR 03:14:26 Error scheduling jobs: Illegal characters for this position: 'CAT'
System.FormatException: Illegal characters for this position: 'CAT'
   at Quartz.CronExpression.StoreExpressionVals(Int32 pos, String s, Int32 type)
   at Quartz.CronExpression.BuildExpression(String expression)
   at Quartz.CronExpression..ctor(String cronExpression)
   at Quartz.CronTrigger.set_CronExpressionString(String value)
   at Quartz.CronTrigger..ctor(String name, String group, String jobName, String jobGroup, DateTime startTimeUtc, Nullable`1 endTime, String cronExpression)
   at Quartz.Xml.JobSchedulingDataProcessor.ProcessJobs(quartz data)
   at Quartz.Xml.JobSchedulingDataProcessor.ProcessInternal(String xml)
   at Quartz.Xml.JobSchedulingDataProcessor.ProcessFile(String fileName, String systemId)
   at Quartz.Xml.JobSchedulingDataProcessor.ProcessFileAndScheduleJobs(String fileName, String systemId, IScheduler sched, Boolean overwriteExistingJobs)
   at Quartz.Plugin.Xml.JobInitializationPlugin.ProcessFile(JobFile jobFile)

Many thanks to our friend Lane McLaughlin for figuring out this goo… everyone loves a log.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: