【发布时间】:2016-06-26 20:20:39
【问题描述】:
我有一个使用 NLog nuget 包的 .NET 项目。我想将此移植到 .NET Core - 但 NLog 不能与 .NET Core 一起使用。
NLog 部分基于 System.Configuration 命名空间 - 似乎没有在 .NET Core Framework 中实现。
那么,我可以使用的 nuget 上是否有其他日志库支持 .NET Core?
【问题讨论】:
我有一个使用 NLog nuget 包的 .NET 项目。我想将此移植到 .NET Core - 但 NLog 不能与 .NET Core 一起使用。
NLog 部分基于 System.Configuration 命名空间 - 似乎没有在 .NET Core Framework 中实现。
那么,我可以使用的 nuget 上是否有其他日志库支持 .NET Core?
【问题讨论】:
.Net Core 预计会出现在 NLog 4.4 中。它现在处于测试状态,但您可以尝试一下。你可以找到nuget包here。
我在this project看到成功使用Serilog,所以你也可以试试。
【讨论】:
我遇到了同样的问题,但后来我发现 NLog 的稳定版本是
“NLog”:“4.3.5”
您可以在依赖项区域的 projet.json 文件中添加上述引用。
> {
"version": "1.0.0-*",
"description": "Business Class Library",
"authors": [ "Salman.tariq.lone" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": {
"dependencies": {
"Data": "1.0.0-*",
"NLog": "4.3.5",
"HtmlAgilityPack": "1.4.9",
"RestSharp": "105.2.3",
"Unofficial.Ionic.Zip": "1.9.1.8"
}
}
},
"dependencies": {
"LibGit2Sharp": "1.0.0-*"
},
"compilationOptions": {
"allowUnsafe": true
}
}
以上部分是我的 project.json 文件,您可以在其中看到 NLog 参考。它在我的情况下工作。
【讨论】: