问题描述
我正在制作 .net core 2 Web 应用程序的原型.我被要求使用 Log4Net 来处理我们的日志记录,但我想将它放在 .net 框架 4.6.1 包装器项目中,以便允许更改内部日志记录系统,而无需更新整个过程中的所有方法调用网站.
I'm prototyping a .net core 2 web application. I've been asked to use Log4Net for handling our logging, but I want to put it in a .net framework 4.6.1 wrapper project as to allow for changing out the internal logging systems without having to update all of the method calls throughout the site.
到目前为止我发现的一切都是为了做一个或另一个.4.6.1封装log4net或者直接引用.net core.
Everything that I've found so far is for doing one or the other. Wrapping the log4net in 4.6.1 or doing a direct reference to the .net core.
到目前为止,我的两个主要异常是FileNotFoundException";因为当我将它用作直接引用时,或者当我在 Framework proejct 文件中执行 PackageReference 时,我得到一个日志记录与 netcoreapp2.0 不兼容.日志记录是框架 4.6.1.
So far, my 2 main exceptions are "FileNotFoundException" for when I use it as a direct reference, or when I do the PackageReference in the Framework proejct files I get a "Logging is not compatible with netcoreapp2.0. Logging is framework 4.6.1.
推荐答案
首先,我建议您使用 .NET 标准 1.3 制作包装器,因为这是 log4net 当前支持的 .NET 核心版本,此外,这将使您能够在 .NET Core 和 .NET Framework 4.6 及更高版本中引用此包装器.
First, I would recommend making your wrapper using .NET standard 1.3 as this is the currently .NET core version supported by log4net, plus, this would allow you to reference this wrapper in .NET core and .NET framework 4.6 and up.
二见:https://stackify.com/making-log4net-net-core-work/ 有关让 log4net 与 .NET core 一起工作的更多信息.
Second, see: https://stackify.com/making-log4net-net-core-work/ for some more info on getting log4net working with .NET core.
这篇关于带有 .net core 2 和框架 Wrapper 的 Log4Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!