user590849
user590849

Reputation: 11765

how to check what users are accessing my tomcat server running in eclipse (java web development)?

I am developing a java web application and I am using Tomcat installed in Eclipse for my development. I want to see which computers are accessing my website (running on Tomcat) for testing purposes.

I tried netstat but that is not showing me the required data.

I am developing on a Red Hat desktop.

Thank you in advance.

Upvotes: 0

Views: 2414

Answers (1)

Paul Vargas
Paul Vargas

Reputation: 42030

You need configure in the file server.xml in Server/Service/Engine:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log." suffix=".txt"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />

See more in The Valve Component

UPDATE

For to see the log file using the tail command, you need to know the location of this log file. Using the previously defined names in Valve example, we can have in a servlet or jsp:

<%
    String location = System.getProperty("catalina.base") + 
    java.io.File.separator + "logs" + java.io.File.separator + 
    "localhost_access_log." + new java.sql.Date(System.currentTimeMillis()) +
    ".txt";
%>

Example with tail:

tail -f /home/paul/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/logs/localhost_access_log.2013-05-30.txt

Upvotes: 1

Related Questions