Post Serilog 记录到 Rest api

Post Serilog logs to Rest api

我想使用 Serilogger 将我的 .net 核心服务器的日志写入 Rest-api。我已经检查了几种方法,并通过让我休息 api 的 url 来尝试 Seq sink。但它不能有效地工作。 有没有rest api sink?感谢您的帮助

"Serilog": {
    "Using": [ "Serilog", "Serilog.Sinks.Console", "Serilog.Sinks.Seq" ],
    "MinimumLevel": {
      "Default": "Verbose",
      "Override": {
        "System": "Information",
        "Microsoft": "Information",
        "Microsoft.EntityFrameworkCore": "Information"
      }
    },
    "WriteTo": [
      {
        "Name": "Seq",
        "Args": {
          "serverUrl": "http://localhost:6010",
          "apiKey": "none",
          "restrictedToMinimumLevel": "Verbose"
        }
      },
      {
        "Name": "Async",
        "Args": {
          "configure": [
            {
              "Name": "Console",
              "Args": {
                "restrictedToMinimumLevel": "Information"
              }
            }
          ]
        }
      }
    ],

您可以尝试 Serilog.Sinks.Http,一个用于通过 HTTP 发送日志事件的 Serilog 接收器。

下面是一个假设的 JSON 负载示例:

{
  "events": [
    {
      "Timestamp": "2020-03-31T00:05:30.4899425-03:00",
      "Level": "Information",
      "MessageTemplate": "Logging {@Heartbeat} from {Computer}",
      "RenderedMessage": "Logging { UserName: \"augustoproiete\", UserDomainName: \"XLSTACK\" } from \"Workstation\"",
      "Properties": {
        "Heartbeat": {
          "UserName": "augustoproiete",
          "UserDomainName": "XLSTACK"
        },
        "Computer": "Workstation"
      }
    },
    {
      "Timestamp": "2020-03-31T00:09:12.4905685-03:00",
      "Level": "Information",
      "MessageTemplate": "Logging {@Heartbeat} from {Computer}",
      "RenderedMessage": "Logging { UserName: \"augustoproiete\", UserDomainName: \"XLSTACK\" } from \"Workstation\"",
      "Properties": {
        "Heartbeat": {
          "UserName": "augustoproiete",
          "UserDomainName": "XLSTACK"
        },
        "Computer": "Workstation"
      }
    }
  ]
}

在 Serilog 的 wiki 中,您可以找到由更广泛的 Serilog 社区开发和支持的接收器列表: https://github.com/serilog/serilog/wiki/Provided-Sinks