在我的ASP.NET MVC 5项目中,我使用Castle Windsor库来解析依赖关系。 现在通过Nuget安装了Castle.Core和Castle.Windsor。 我需要记录功能,所以我安装了Castle.Windsor-log4net Nuget包。
我尝试注册log4net工具以便将来在我的控制器中解析并获得异常:
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;
}
}
}
Castle.Windsor.dll中出现“Castle.MicroKernel.SubSystems.Conversion.ConverterException”类型的异常,但未在用户代码中处理
其他信息:无法将字符串'Castle.Services.Logging.Log4netIntegration.Log4netFactory,Castle.Services.Logging.Log4netIntegration,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 407dd0808d44fbdc'转换为类型。
现在我的web项目引用了下一个程序集: 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
我使用下一个配置配置了log4net:
<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>
和部分
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" />
这是好的配置,还是没有问题? 我该如何解决此异常?