【问题标题】:how to check what users are accessing my tomcat server running in eclipse (java web development)?如何检查哪些用户正在访问我在 Eclipse(Java Web 开发)中运行的 tomcat 服务器?
【发布时间】:2013-05-29 22:28:32
【问题描述】:

我正在开发一个 java web 应用程序,并且我正在使用安装在 Eclipse 中的 Tomcat 进行开发。我想查看哪些计算机正在访问我的网站(在 Tomcat 上运行)以进行测试。

我尝试了 netstat,但没有显示所需的数据。

我正在 Red Hat 桌面上进行开发。

提前谢谢你。

【问题讨论】:

  • 配置AccessLogValve

标签: java eclipse tomcat network-monitoring


【解决方案1】:

你需要在Server/Service/Engine的server.xml文件中配置:

<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" />

The Valve Component中查看更多信息

更新

要使用tail 命令查看日志文件,您需要知道此日志文件的位置。使用之前在Valve 示例中定义的名称,我们可以在 servlet 或 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";
%>

tail 为例:

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

【讨论】:

  • 我猜想查看用户日志我还需要添加 -f tail 吗?我应该在哪里添加 -f tail ?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-18
  • 2015-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多