Serilog MSSQL sink additional columns not populated - Stack Overflow

I am trying to use Serilog in my .NET application to write logs to a table.I have added 4 additional c

I am trying to use Serilog in my .NET application to write logs to a table. I have added 4 additional columns to the standard schema for Serilog tables. Following is the relevant portion of my appsettings.json:

"columnOptionsSection": {
  "additionalColumns": [
    {
      "ColumnName": "HTTPMethod",
      "DataType": "nvarchar",
      "DataLength": 50
    },
    {
      "ColumnName": "Endpoint",
      "DataType": "nvarchar",
      "DataLength": 256
    },
    {
      "ColumnName": "Body",
      "DataType": "nvarchar",
      "DataLength": 4000
    },
    {
      "ColumnName": "Headers",
      "DataType": "nvarchar",
      "DataLength": 4000
    }
  ]
}

When I try to log I am doing this:

    _logger.ForContext("SourceContext", "ApiRequest").Information("{@LogEvent}", new APIRequestLogModel2
    {
        HttpMethod = "test",
        Endpoint = "endpoint",
        Body = "Body",
        Headers = "Headers"
    });

APIRequestLogModel2 is the following POCO class:

public class APIRequestLogModel2
{
    public string HttpMethod { get; set; }
    public string Endpoint { get; set; }
    public string Body { get; set; }
    public string Headers { get; set; }
}

The log gets created but all additional columns are null. What am I missing? Is there any additional configuration needed? Couldn't find much on Serilog doc.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745300722a4621419.html

相关推荐

  • Serilog MSSQL sink additional columns not populated - Stack Overflow

    I am trying to use Serilog in my .NET application to write logs to a table.I have added 4 additional c

    14小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信