title: Need to log asp.net webapi 2 request and response body to a database
body: <p>I am using Microsoft Asp.net WebApi2 hosted on IIS. I very simply would like to log the request body (XML or JSON) and the response body for each post.</p>
  
  <p>There is nothing special about this project or the controller processing the post. I am not interested in using logging frameworks like nLog, elmah, log4net, or the built-in tracing features of web API unless it is necessary to do so.</p>
  
  <p>I am simply wanting to know where to put my logging code and how to get the actual JSON or XML from the incoming and outgoing request and response.</p>
  
  <p>My controller post method:</p>
  
  <pre><code>public HttpResponseMessage Post([FromBody])Employee employee)
  {
     if (ModelState.IsValid)
     {
        // insert employee into to the database
     }
  
  }
  </code></pre>