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
评论列表(0条)