Download loggingproxy and extract the zip file containing the source and examples.
Example 1 without Logging
Copy the lp.war in the example1WithoutLogging directory to the webapp folder of your Tomcat Server and start Tomcat. This proxies to http://jambula.sourceforge.net/.
Open http://localhost:8080/lp/ in a browser. It should open the Jambula homepage.
Check web.xml under the expanded loggingproxy directory for the configuration used.
Stop Tomcat and delete the loggingproxy directory for the next example.
Example 2 with Logging and multiple destinations
Copy the lp.war in the example2WithLoggingAndMultipleDestinations directory to the webapp folder of your Tomcat Server and start Tomcat. This proxies to http://jambula.sourceforge.net/ for URLs starting with /jm and to http://aredis.sourceforge.net/ for URLs starting with /ar
Open http://localhost:8080/lp/jm/ in a browser. It should open the Jambula homepage.
Open http://localhost:8080/lp/ar/ in a browser. It should open the AREDIS homepage.
Check web.xml under the expanded loggingproxy directory for the configuration used.
You can see the logs under work/Catalina/localhost/lp/reqres under Tomcat installation directory. You won't find request.txt files because the requests are all GET requests without a POST body.
Deploying as ROOT webapp
You can also deploy loggingproxy Servlet as a ROOT webapplication so that you can access the proxy URL without the /lp prefix. To do this copy webapps/lp/WEB-INF to webapps/ROOT.
Startup dependency on proxy
If there is a startup dependency on a URL proxied by loggingproxy by another web application deployed on the same server, Tomcat will not start because of the cyclic dependency caused due to the Proxy Servlet itself waiting for Tomcat to come up.
To overcome this you can define a second host entry as shown in serverWithMultipleHosts.xml. Edit server.xml and similarly copy paste the Host section and add the attribute deployOnStartup="false" to the current host section only.
In the pasted host entry change the host name as org.loggingproxy. You can add the alias tags as shown for org.lp for additional host names. Also change the appBase to webappsLoggingProxy.
Next create webappsLoggingProxy directory defined in the new Host under Tomcat root and copy paste the host-manager and ROOT directories from webapps.
Deploy the example2 lp.war under webappsLoggingProxy after deleting loggingproxy directory and war from webapps directory.
Add host entries for org.loggingproxy and org.lp to point to 12.0.0.1.
Open http://org.loggingproxy:8080/lp/ar/ or http://org.lp:8080/lp/ar/ in a browser. It should open the AREDIS homepage.
The above URLs can be used by apps deployed under webapps directory even during their startup because they get loaded after Tomcat is up with loggingproxy Servlet.
The request logs are created under <TOMCAT_HOME>/work/Catalina/org.loggingproxy/lp/reqres.
Older Java Versions
The LoggingProxyServlet.class is compiled with Java 8. If you have an older Java version please re-compile the java file. You will need to change the source to use SimpleDateFormat instead of DateTimeFormatter to do the date formatting. Use a new instance inside the service method since it is not Threadsafe.