tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: logging outgoing requests from Tomcat to SQL
Date Wed, 28 Jan 2009 18:39:23 GMT
Hash: SHA1


Gergely Paljak wrote:
> A want to realize a logging system for tomcat that is capable of:
> - logging the incoming request for Servlets (easy)
> - and logging the time when the Tomcat response is sent (easy as well)

As you say, these are relatively easy to accomplish.

> - logging the outgoing SQL queries inside Tomcat while maintaining a mapping
> between the requested Servlet and the sent SQL queries
> - logging the incoming SQL query results

I think your best bet is to implement your own DataSource that extends
Tomcat's built-in datasource (or some other one, if you like). Have your
DataSource return Connection objects that wrap the ones provided by
Tomcat's DataSource object.

Your Connection class should produce wrapped Statement classes that log
the statements as they are executed, and wrapped ResultSet objects that
do ... something else. Due to the specific JDBC spec requirements about
how results are read, you may have to settle for only reading those
values /actually read/ by the application, instead of the entire result set.

I have implemented JDBC interface wrappers before, and they are
completely miserable to do (just sooo much plumbing code). I wrote a
super-sexy class wrapper generator if you're interested in doing
something like this.

- -chris
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message