Search code examples
mavenjettyembedded-jetty

Enable tracing of requests and responses with jetty-maven-plugin


I have a working maven project with a properly configured jetty-maven-plugin for tests.

If I run mvn -X jetty:run, among all debug outputs, I see the trace of all HTTP requests and responses, including received and sent headers.

Alas, the maven debug output is very verbose. Is there some way to configure the plugin, or jetty itself via its xml files, to get the same trace without all other debug outputs?

Please note that I'm not interested in configuring a simple access log, which won't display headers.


Solution

  • You could configure the Jetty CustomRequestLog, with this you can supply a custom format code which allows you to output the headers that you want to see. The javadoc explains the usage and the different format codes available. You can easily enable this with jetty customrequestlog startup module or copying the jetty-customrequestlog.xml file.

    If that's not good enough then you could also create your own implementation of the RequestLog interface and log whatever you want using the request and response. You can then add this to the server with server.setRequestLog(...) or equivalent xml.