You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Dabbs <dm...@gmail.com> on 2010/10/02 20:40:45 UTC

How best to get some data from a Servlet to Apache access log. . .

Hello.

I'm running Tomcat fronted by Apache httpd via mod_proxy_ajp.
There's a small bit of data from my Servlet response I'd like to 
get into the Apache access_log.

I know I could set a response header, say X-MyData, and log
that using a CustomLog directive. But I don't want this header
cruft going out with the response from Apache. Would I use mod_headers
to remove this header (and yet still log to access_log)?

Another possibility is to use a "note," which I can also log
using CustomLog. It's not clear though, how I would set this note
using the Response obj available to my servlet code and have it 
propagate back through AJP.

Looking for the best way to skin this cat.

Thanks!

David



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How best to get some data from a Servlet to Apache access log. . .

Posted by Rainer Jung <ra...@kippdata.de>.
On 02.10.2010 20:40, David Dabbs wrote:
> Hello.
>
> I'm running Tomcat fronted by Apache httpd via mod_proxy_ajp.
> There's a small bit of data from my Servlet response I'd like to
> get into the Apache access_log.
>
> I know I could set a response header, say X-MyData, and log
> that using a CustomLog directive. But I don't want this header
> cruft going out with the response from Apache. Would I use mod_headers
> to remove this header (and yet still log to access_log)?
>
> Another possibility is to use a "note," which I can also log
> using CustomLog. It's not clear though, how I would set this note
> using the Response obj available to my servlet code and have it
> propagate back through AJP.
>
> Looking for the best way to skin this cat.

Notes can only be set from within an Apache module. A response header is 
the only thing that survives passing the response from Tomcat to Apache. 
And yes, you should be able to remove the header with mod_headers, but: 
I would expect that the header is then gone for Apache mod_log_config to :(

Would it suffice to log things in a Tomcat access log (can log e.g. 
request attributes, which are not sent to the client), and generate a 
unique ID there that you send back to Apache (and the client) and log 
there too, so that you can correlate one to one?

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org