Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Does "Tomcat standalone" log every HTTP GET request by default?

  • If yes, where are every HTTP GET requests logged by default? (how could I have found them myselves?)

  • If no, can "Tomcat standalone" be configured to log every HTTP GET request?

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.

like image 429
NoozNooz42 Avatar asked Jun 10 '10 18:06

NoozNooz42


People also ask

How many HTTP requests can a Tomcat server handle?

The default installation of Tomcat sets the maximum number of HTTP servicing threads at 200. Effectively, this means that the system can handle a maximum of 200 simultaneous HTTP requests.

What does access logs in Tomcat or any other webserver contain?

The access log contains the information for each request that hits the server. It can be used to track page hit counts, user session activity, and so on because it logs all the incoming requests along with Timestamp, Request HTTP Method and the HTTP Response code.

Where can I find Tomcat application logs?

This file is located in the logs directory below the Tomcat root directory. This log is the system's output log, which also consists of standard error messages. These files are saved daily (MM-DD-YYYY) with the date appended to the name of the data. Moreover, this log file persists during the functioning of the server.


1 Answers

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"/> 
like image 164
Richard Fearn Avatar answered Sep 28 '22 04:09

Richard Fearn