Kle*_*lee 8 c# nlog common.logging
我有一个Wpf .net 4.0 C#项目,我试图从使用Log4Net迁移到使用NLog作为Common.LoggingFaçade后面的日志库.我原本以为这是一件容易的事,但你知道他们说的是什么,没有什么比这更容易了.
我用过NuGet来:
在app.config文件中我有:
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog">
<arg key="configType" value="FILE" />
<arg key="configFile" value="~/NLog.config" />
</factoryAdapter>
</logging>
</common>
Run Code Online (Sandbox Code Playgroud)
......而且......
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,我收到一个错误说明
'在类型'NameSpace.Shell.AppBootstrapper'上调用与指定绑定约束匹配的构造函数引发了异常.行号'8'和行位置'18'.
内在的例外是:
{"无法加载一个或多个请求的类型.请检索LoaderExceptions属性以获取更多信息."}
说Loader异常,只有一个,是:
{"无法从程序集'NLog加载类型'NLog.TargetWithLayout',Version = 2.0.1.0,Culture = neutral,PublicKeyToken = 5120e14c03d0593c'.":"NLog.TargetWithLayout"}
有没有人克服这个问题或有解决方法NLog working with Common.Logging?
为了不发布长期问题,我没有包含该NLog.config文件,但我可以,如果这将是有益的.
Kle*_*lee 15
在我问了这个问题后,很多人四处寻找,在我问这个问题之前我做了很多搜索.我尝试各种各样的东西,并希望它们可以工作.
我发现Common.Logging.NLog.NLogLoggerFactoryAdapter我正在使用的是来自Common.Logging.Nlogdll,并且dll有一个参考,NLog 1.0.0.505它使用旧的位置为NLog.TargetWithLayout类.
我Common.Logging.Nlog用NuGet 删除了包,并将app.config文件中的引用更改为:
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
Run Code Online (Sandbox Code Playgroud)
然后,它使用在NLog 2.0.1.2包中找到的正确类,并允许NLog和应用程序启动.
我希望这可以帮助其他任何偶然发现这个问题的人.我找不到其他人记录如何处理它.
| 归档时间: |
|
| 查看次数: |
5416 次 |
| 最近记录: |