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

StackOverflow https://stackoverflow.com/questions/16824975

質問

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.

役に立ちましたか?

解決

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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top