I\'m using Elmah to log exceptions. Elmah is great at logging request bodies if the request is a Form-based request (i.e. Content-Type: application/x-www-form-urlencoded),
first install nuget package : Newtonsoft.Json
install-package Newtonsoft.Json
then:
public override void OnException(HttpActionExecutedContext filterContext)
{
var message = new StringBuilder();
foreach (var param in filterContext.ActionContext.ActionArguments)
{
message.Append(string.Format("{0}:{1}\r\n", param.Key, Newtonsoft.Json.JsonConvert.SerializeObject(param.Value)));
}
var ex = new Exception(message.ToString(), filterContext.Exception);
var context = HttpContext.Current;
ErrorLog.GetDefault(context).Log(new Error(ex, context));
}