NoozNooz42
NoozNooz42

Reputation: 4328

Java/Tomcat standalone, how to log/access all the HTTP GET requests

I'm running Tomcat in standalone mode. The "standalone" part is very important: I am not going to install Apache in front of Tomcat.

In my question here, about how to implement a "web bug", I got a great answer: Java webapp: how to implement a web bug (1x1 pixel)?

However the answer states:

In your access logs, you can count for your jpg - the output should be"

127.0.0.1 - - [10/Jun/2010:11:38:53 +0530] "GET /mywebapp/jsp/invisible.jpg?1276150133362 HTTP/1.1" 200 991

But, as I feared, I cannot find such logs.

... $ cat apache-tomcat-6.0.26/logs/* | grep GET | wc -l

0

There are a lot of logs. My webapp's custom logs are definitely logged.

So I've got a few related questions:

Note that I know that in my case I can add custom logging alongside with my web bug .jsp and search for that in the logs, but that is not my question here.

My question here is really about how Tomcat standalone (once again, the standalone is very important) deals with logging of all the HTTP GET requests.

Upvotes: 40

Views: 53462

Answers (1)

Richard Fearn
Richard Fearn

Reputation: 25481

It doesn't log requests by default, but will do if you uncomment this valve in conf/server.xml:

<Valve className="org.apache.catalina.valves.AccessLogValve"
    directory="logs" prefix="localhost_access_log." suffix=".txt"
    pattern="common" resolveHosts="false"/>

Upvotes: 61

Related Questions