首页 > 解决方案 > 使用 HttpClient 的 NLog 重复属性

问题描述

我有来自我的 HttpClient 的 nLog 日志记录请求,然后将该数据写入 Kinesis 中的流,该流传送到 AWS Elastic Search。我的大多数日志都可以正常交付,但有些日志无法交付,因为它们在 JSON 有效负载中具有重复的对象键。

这是失败日志的示例

{
    "Application": "TestApplication",
    "Environment": "DEV",
    "HostName": "xxxxxxxxx",
    "@timestamp": "2021-06-16T05:17:53.005+00:00",
    "Level": "INFO",
    "Logger": "System.Net.Http.HttpClient.Default.LogicalHandler",
    "Message": "Start processing HTTP request POST https:\/\/example.com/",
    "ConnectionId": "xxxxxxxxx",
    "RequestId": "xxxxxxxxxx",
    "RequestPath": "\/somepath\/someotherpath",
    "CorrelationId": "xxxxxxxxxxxx",
    "ActionId": "xxxxxxxxxxxxx",
    "ActionName": "xxxxxxxxxxx",
    "HttpMethod": "POST",
    "Uri": "https:\/\/example.com\/",
    "HttpMethod": "POST", <----- Dupe
    "Uri": "https:\/\/example.com\/", <----- Dupe
    "EventId_Id": 100,
    "EventId_Name": "RequestPipelineStart",
    "EventId": "RequestPipelineStart"
}

注意上面有两个重复的键HttpMethodUri. 我不知道从哪里开始调试,因为这似乎是直接来自其中LogicHandler一些失败日志或`ClientHandler.

有没有人遇到过这个?

标签: c#jsonelasticsearchamazon-kinesis

解决方案


推荐阅读