We are currently using Serilog in ASP.NET Core WebApi with its standard middleware UseSerilogRequestLogging, which captures enough information for all GET cases. Now I am trying to figure out, couple of things.
- In case of POST, if I want to log the request body, only in case of failures (response code > 299), is there an existing option that I can use?
- If I am able to log the request body, how do I write it to separate sink so that I can push info to a separate destination ?
Just FYI, we are using file logging on VMs and console logging in Container. These are eventually forwarded to Splunk. We are using .Net 6.0
Thanks!