如何在tomcat中记录/调试不良请求?

时间:2012-06-11 11:07:50

标签: http tomcat tomcat6 bad-request

在我们的系统(封闭系统,tomcat 6中的java web应用程序作为服务器,java胖客户端)中,我们的客户偶尔会显示“400 - 错误请求”响应。我想在服务器端调试这个,但由于请求似乎无效,我在任何地方都看不到它们。我为完整的tomcat主机配置了AccessLogValve,但请求没有出现在那里。我甚至没有在catalina.out中看到任何东西。

我希望能够记录这些请求,更好的方法是根据某些标准转储请求。

有什么想法吗?

我的server.xml如下所示:

<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
rmiServerPortPlatform="9098"
rmiRegistryPortPlatform="9099"
useLocalPorts="true" />
  <Service name="Catalina">
    <Connector port="8020" protocol="HTTP/1.1" redirectPort="8010" connectionTimeout="20000" />
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="cc1">
      <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="false"
         deployOnStartup="true" xmlValidation="false" xmlNamespaceAware="false">
        <Valve className="org.apache.catalina.valves.AccessLogValve"
               directory="logs" prefix="access_log."
               suffix=".txt" pattern="combined" resolveHosts="false" />
      </Host>
    </Engine>
  </Service>
</Server>

1 个答案:

答案 0 :(得分:1)

很久以前 - 但无论如何:Tomcat有不同的阀门可能有助于实现这一点:http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Request_Dumper_Valve

另一种选择是tcpdump,因为它是HTTP和响应代码,似乎可以过滤导致这种情况的原始请求。