Search code examples
c#asp.net-corenlog

How to rlog request body as a string in Nlog


I am using ${aspnet-request-post-body} to log the request body in log file. The problem I am facing is I want to prevent ${aspnet-request-post-body} to log request body in Json format

{
   "Person": {
        "age": 12,
        "height": 0
        
    },
      "Employee": {
        "age": 12,
        "height": 0,
        
    },
      

}

All I want is to log the request body in string format or in compact form because in Json format the request body is taking too much space in file. Any solution will be highly appreciated???


Solution

  • so I converted the my custom object in json format and then into string that also compact the object and then logged.