具有.net core 2和框架包装的Log4Net [英] Log4Net with .net core 2 and framework Wrapper

查看:329
本文介绍了具有.net core 2和框架包装的Log4Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作.net core 2 Web应用程序的原型.我曾被要求使用Log4Net来处理日志记录,但是我想将其放入.net Framework 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核心.

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.

请协助.我很想找到解决这个问题的方法.

Please assist. I would love to find a way around this.

推荐答案

首先,我建议您使用.NET standard 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.

祝你好运.我希望这会有所帮助.

Good luck. I hope this helps.

这篇关于具有.net core 2和框架包装的Log4Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆