title: Spring Boot: getting query string parameters and request body in AuditApplicationEvent listener
body: <p>Spring Boot REST app here. I'm trying to configure Spring Boot request auditing to log each and every HTTP request that any resources/controllers receive with the following info:</p>
  
  <ol>
  <li>I need to see in the logs the exact HTTP URL (path) that was requested by the client, including the HTTP method <strong>and any query string parameters</strong>; and</li>
  <li>If there is a request body (such as with a POST or PUT) I need to see the contents of that body in the logs as well</li>
  </ol>
  
  <p>My best attempt so far:</p>
  
  <pre><code>@Component
  public class MyAppAuditor {
      private Logger logger;
  
      @EventListener
      public void handleAuditEvent(AuditApplicationEvent auditApplicationEvent) {
          logger.info(auditApplicationEvent.auditEvent);
      }
  }
  
  public class AuditingTraceRepository implements TraceRepository {
      @Autowired
      private ApplicationEventPublisher applicationEventPublisher
  
      @Override
      List&lt;Trace&gt; findAll() {
          throw new UnsupportedOperationException("We don't expose trace information via /trace!");
      }
  
      @Override
      void add(Map&lt;String, Object&gt; traceInfo) {
          Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
          AuditEvent traceRequestEvent = new AuditEvent(new Date(), "SomeUser", 'http.request.trace', traceInfo);
          AuditApplicationEvent traceRequestAppEvent = new AuditApplicationEvent(traceRequestEvent);
  
          applicationEventPublisher.publishEvent(traceRequestAppEvent);
      }
  }
  </code></pre>
  
  <p>However at runtime if I use the following curl command:</p>
  
  <pre><code>curl -i -H "Content-Type: application/json" -X GET 'http://localhost:9200/v1/data/profiles?continent=NA&amp;country=US&amp;isMale=0&amp;height=1.5&amp;dob=range('1980-01-01','1990-01-01')'
  </code></pre>
  
  <p>Then I only see the following log messages (where <code>MyAppAuditor</code> send audit events):</p>
  
  <pre><code>{ "timestamp" : "14:09:50.516", "thread" : "qtp1293252487-17", "level" : "INFO", "logger" : "com.myapp.ws.shared.auditing.MyAppAuditor", "message" : {"timestamp":"2018-06-29T18:09:50+0000","principal":"SomeUser","type":"http.request.trace","data":{"method":"GET","path":"/v1/data/profiles","headers":{"request":{"User-Agent":"curl/7.54.0","Host":"localhost:9200","Accept":"*/*","Content-Type":"application/json"},"response":{"X-Frame-Options":"DENY","Cache-Control":"no-cache, no-store, max-age=0, must-revalidate","X-Content-Type-Options":"nosniff","Pragma":"no-cache","Expires":"0","X-XSS-Protection":"1; mode=block","X-Application-Context":"application:9200","Date":"Fri, 29 Jun 2018 18:09:50 GMT","Content-Type":"application/json;charset=utf-8","status":"200"}},"timeTaken":"89"}} }
  </code></pre>
  
  <p>So as you can see, the auditor is picking up the base path (<code>/v1/data/profiles</code>) but is not logging any of the query string parameters. I also see a similar absence of request body info when I hit POST or PUT endpoints that do require a request body (JSON).</p>
  
  <p><strong>What do I need to do to configure these classes (or other Spring classes/configs) so that I get the level of request auditing that I'm looking for?</strong></p>