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

The Castle Windsor Quartz.Net facility is pretty awesome, it making getting up and running a fairly painless process.  However, when things go wrong, 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 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:


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

<bindingRedirect oldVersion="" newVersion=""/>


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

<sectionGroup name="common">

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


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



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

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

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




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.

  1. Leave a comment

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: