Reputation: 5119
I am trying to use Quartz 2.1.2 with logging, but I keep getting the following output when I debug:
no configuration section found - suppressing logging output
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 I was doing wrong was not including the App.config file in my unit test project. Once I did that, I got a different error:
Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'
I didn't see Log4Net in the Common.Logging namespace so I added the DLL via Package Manager, but I still get the same error. I am using Common.Logging version 2.1.2. Any ideas why I am still having an issue?
Upvotes: 5
Views: 11938
Reputation: 806
You can install the Common.Logging.Log4Net1211 and change the appsetting as following
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1211">
<arg key="configType" value="INLINE"/>
</factoryAdapter>
</logging>
</common>
Note that dll name changed to "Common.Logging.Log4Net1211".
Upvotes: 0
Reputation: 758
Try putting the Common.Logging library in the same folder as your Quartz library (C5 should also be there). As far as I know, you don't have to reference it from within Visual Studio.
Upvotes: 0
Reputation: 35587
first of all check that you have all the packages (assemblies) updates. This is my nuget packages.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 reckon that you have to force-update Common.Logging.Log4Net
cause Quartz.net doesn't download the latest version.
Then check your App.config. You should have this binding:
<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're using the wrong appender. You seem you want to write your log in a file but you're using EventLogAppender.
If you want to use file system you can try with this config 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>
You might have problems with permissions trying to write in that folder. If you want to put your logs in the bin folder if your app change this:
<param name="File" value="Scheduler.log" />
Upvotes: 3