.net Core 2.0控制台应用程序中的log4net

时间:2018-08-13 18:49:44

标签: .net-core console-application log4net .net-core-2.0

log4net Microsoft.Extensions.Logging.Log4Net.AspNetCore运行中使用2.2.4

dotnet publish -c release -r win81-x64 

导致这些错误:

:: error NU1605: Detected package downgrade: System.Net.NameResolution from 4.3.0 to 4.0.0. Reference the package directly from the project to select a different version.
:: error NU1605:  DailyPieChartUpdate -> Microsoft.Extensions.Logging.Log4Net.AspNetCore 2.2.4 -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Net.NameResolution (>= 4.3.0)
:: error NU1605:  DailyPieChartUpdate -> Microsoft.Extensions.Logging.Log4Net.AspNetCore 2.2.4 -> log4net 2.0.8 -> System.Net.NameResolution (>= 4.0.0)
:: error NU1605: Detected package downgrade: System.Net.Primitives from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
:: error NU1605:  DailyPieChartUpdate -> Microsoft.Extensions.Logging.Log4Net.AspNetCore 2.2.4 -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Net.Primitives (>= 4.3.0)
:: error NU1605:  DailyPieChartUpdate -> Microsoft.Extensions.Logging.Log4Net.AspNetCore 2.2.4 -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> System.Net.Primitives (>= 4.0.11)
  Restore failed in 588.96 ms 

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

第1步是进入您的项目文件,并确保您仅引用了一个版本的log4net, 第2步是清理本地nuget包 步骤3是重新获取所有nuget程序包

希望能解决您的问题

最好参考.net核心的最新log4net版本。

答案 1 :(得分:0)

也许我待会儿回答的时间太多了,但是...

我认为的问题是由于项目中某些已经导入的库降级了Microsoft.Extensions.Logging.Log4Net.AspNetCore nuget所引用的导入库。

还有其他用户也遇到相同问题。您可以检查this github issue找出解决方案。

很抱歉给您带来不便。