In my ASP.NET MVC 5 project I use Castle Windsor library to resolve dependencies. Now installed Castle.Core and Castle.Windsor via Nuget. I need logging feature, so I installed Castle.Windsor-log4net Nuget package.
I try to register log4net facility for future resolving in my controllers and get exception:
public class ContainerFactory
{
private static IWindsorContainer container;
private static readonly object SyncObject = new object();
public static IWindsorContainer Current
{
get
{
if (container == null)
{
container = new WindsorContainer();
// run some installers here
container.AddFacility<LoggingFacility>(f => f.UseLog4Net()); //Exception here
}
return container;
}
}
}
An exception of type 'Castle.MicroKernel.SubSystems.Conversion.ConverterException' occurred in Castle.Windsor.dll but was not handled in user code
Additional information: Could not convert string 'Castle.Services.Logging.Log4netIntegration.Log4netFactory,Castle.Services.Logging.Log4netIntegration,Version=4.0.0.0, Culture=neutral,PublicKeyToken=407dd0808d44fbdc' to a type.
Now in my web project referenced next assemblies: Castle.Core v 4.0.0 Castle.Windsor v 4.0.0 Castle.Facilities.Logging v 4.0.0 Castle.Services.Logging.Log4netIntegration v 3.3.0.0
I configured log4net with next config:
<log4net xsi:noNamespaceSchemaLocation="http://csharptest.net/downloads/schema/log4net.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Logs\Application.log" />
<param name="AppendToFile" value="true" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %m%n" />
</layout>
</appender>
<logger name="LOGGER">
<appender-ref ref="LogFileAppender" />
</logger>
</log4net>
and section
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" />
Is this good configuration, or problem not in it? How can I fix this exception?