I'm trying to use NLog with common.logging for the first time. I implemented NLog in a test project and it all went ok, then tried to apply common.logging but i'm having some dificulties.
Common.logging configuration under App.config
<?xml version="1.0" encoding="utf-8" ?>
<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.NLog10">
<arg key="configType" value="FILE" />
<arg key="configFile" value="~/NLog.config" />
</factoryAdapter>
</logging>
</common>
</configuration>
The error i'm getting is in Common.Logging.LogManager line 317
private static ILoggerFactoryAdapter BuildLoggerFactoryAdapterFromLogSettings(LogSetting setting)
{
...
adapter = (ILoggerFactoryAdapter)Activator.CreateInstance(setting.FactoryAdapterType, args);
...
}
While debugging i can see both configType and configFile args being passed.
My NLog.config is set to always copy in my vs.
The error i get is:
An unhandled exception of type 'Common.Logging.ConfigurationException' occurred in NLogTutorial1.exe
Additional information: Unable to create instance of type Common.Logging.NLog.NLogLoggerFactoryAdapter. Possible explanation is lack of zero arg and single arg NameValueCollection constructors
Visual Studio 2008
Common.Logging version 2.1.1
NLog version 1.5
C# Framework 3.5
Console Project
It seems that using Common.Logging.NLog20 solved the problem. From this site http://netcommon.sourceforge.net/docs/2.1.0/reference/html/ch01.html
Common.Logging.NLog20 -> is linked against NLog 2.0.0.2
Common.Logging.NLog10 -> is linked against NLog 1.0.0.505
So for NLog 1.5 NLog20 should be used.