Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log all request and response data in tomcat

Tags:

java

tomcat

At every moment in the world things change, said some guy.

We're sitting on a big fat REST API server which is becoming more and more of a burden to maintain because good Java developers are hard to find, expensive, development takes much more time, so we're slowly switching various application parts to Rails, which is... well, nevermind.

There are way too many APIs (and some are poorly documented) to just clone functionality by looking at the docs, so my idea is to find a way to log everything that's passing through this service for a while, in a machine-readable format we can later index, process and report, so we can gradually rewrite the code.

Is there a "clean" not so "hacky" way of doing this with Tomcat? Or should I go down the wireshark/reverse proxy way?

TIA!

like image 948
Nick M Avatar asked Feb 20 '14 23:02

Nick M


1 Answers

You can create a payload logging filter and configure it in your web.xml. You can also use an output filter for the response. This and this should be helpful working examples.

like image 143
Guy Bouallet Avatar answered Nov 08 '22 00:11

Guy Bouallet