.net Core - NLog 包

.net Core - NLog package

我有一个使用 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 参考。它在我的案例中有效。