Quartz.NET - configuration section not found <common / logging> - suppress log output
I try to use Quartz 2.1.2 with logging, but when debugging, I get the following output:
configuration section not found - log suppression Exit
Here is my App.config file :
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="common"> <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> </sectionGroup> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <common> <logging> <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net"> <arg key="configType" value="INLINE"/> <arg key="configFile" value="c:\Scheduler.log"/> <arg key="level" value="INFO" /> </factoryAdapter> </logging> </common> <log4net> <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d [%t] %-5p %l - %m%n" /> </layout> </appender> <root> <level value="INFO" /> <appender-ref ref="EventLogAppender" /> </root> </log4net> </configuration> And here is the code for instantiating my Scheduler:
private IScheduler scheduler; public JobScheduler() { ISchedulerFactory schedulerFactory = new StdSchedulerFactory(); this.scheduler = schedulerFactory.GetScheduler(); this.scheduler.Start(); } What am I doing wrong?
UPDATE:
Okay, so one thing that I did wrong was not including the App.config file in my unit test project. As soon as I did this, I had another error:
Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'
I did not see Log4Net in the Common.Logging namespace, so I added the DLL through the package manager, but still get the same error. I am using Common.Logging version 2.1.2. Any ideas why I still have a problem?
First of all, check that you have all the package updates (assemblies). This is my nuget package.config:
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Common.Logging" version="2.1.2" targetFramework="net35" /> <package id="Common.Logging.Log4Net" version="2.0.1" targetFramework="net40" /> <package id="log4net" version="1.2.10" targetFramework="net40" /> <package id="Quartz" version="2.1.2" targetFramework="net35" /> </packages> I believe that you need to force update Common.Logging.Log4Net , because Quartz.net does not download the latest version.
Then check out App.config . This is a binding obligation:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" /> </dependentAssembly> </assemblyBinding> </runtime> I think you are using the wrong appender. It seems you want to write your log to a file, but use EventLogAppender .
If you want to use the file system, you can try with these configuration sections:
<common> <logging> <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net"> <arg key="configType" value="INLINE" /> <arg key="level" value="INFO" /> </factoryAdapter> </logging> </common> <log4net> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="c:\Scheduler.log" /> <param name="AppendToFile" value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="10MB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n" /> </layout> </appender> <root> <level value="INFO" /> <appender-ref ref="LogFileAppender" /> </root> </log4net> Perhaps you may have problems with the access rights that you are trying to write to this folder. If you want to put your logs in the bin folder if your application changes this:
<param name="File" value="Scheduler.log" /> You can install Common.Logging.Log4Net1211 and change the app setting as follows
<common> <logging> <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1211"> <arg key="configType" value="INLINE"/> </factoryAdapter> </logging> </common> Note that the dll name is changed to "Common.Logging.Log4Net1211".