I am working on .NET Framework 4.5.2 NDJSON format I require : Nlog config in xml format for ndjson format given below
{
"timestamp": "[timestamp]",
"level": "[level]",
"severity": "[severity]",
"requestId": "[requestId]",
"httpMethod": "[httpMethod]",
"requestUrl": "[requestUrl]",
"message": "[message]",
"stackTrace": "[stackTrace]"
}
In the above format the following place holders are showing as empty for
httpMethod,requestId,requestUrl:
requestId": "${mdc:item=requestId}",
"httpMethod": "${aspnet-request-method}",
"requestUrl": "${aspnet-request-url}
I already tried an alternative approach to extract the MDC properties and ASP.NET request information directly in the custom layout renderer
Please suggest what method can be used
The NLog JsonLayout can be used to produce output in JSON-format:
You can use NLog Context for providing additional details, and if your are using NLog.Web.AspNetCore then ${aspnet}-LayoutRenderers are available:
By default then NLog ConsoleTarget and NLog FileTarget will add newline-delimeter for each LogEvent. Thus automaticaly output in NDJSON format.