How do I switch from Log4Net to NLog in Quartz.Net?

Brad Bruce picture Brad Bruce · Jul 4, 2011 · Viewed 12.5k times · Source

My company's standard logging tool is NLog. I'm trying to introduce Quartz.net and was asked if it could use NLog instead of Log4Net.

I know I can recompile to use NLog, but I'd like to do it from the configuration files if at all possible.

Answer

LeftyX picture LeftyX · Jul 4, 2011

Assuming that you're using Quartz.net 1.0.3. you have to add a reference to the following assemblies:

Common.Logging
Common.Logging.NLog
NLog

Then you have to add the following configuration in your application's config file:

<configuration>
   <configSections>
      <sectionGroup name="common">
         <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
      </sectionGroup>
   </configSections>

   ...

   <common>
      <logging>
         <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog">
        <arg key="configType" value="FILE" />
        <arg key="configFile" value="~/NLog.config" />
     </factoryAdapter>
      </logging>
   </common>

</configuration>

Note that I am using an external NLog.config file.

NOTE:

Quartz.net uses Common.Logging version 1.2.