Tomcat 7无法写入访问日志并引发以下异常。
Nov 17, 2016 5:10:37 PM org.apache.catalina.connector.CoyoteAdapter log
WARNING: Exception while attempting to add an entry to the access log
java.lang.NullPointerException
at org.apache.catalina.connector.CoyoteAdapter.log(CoyoteAdapter.java:555)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:182)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
如何解决这个问题?
答案 0 :(得分:0)
这是Tomcat中已知的问题,已在Tomcat 8.0.29中修复。升级Tomcat应该可以解决此问题。 https://bz.apache.org/bugzilla/show_bug.cgi?id=58578
其他方法是修改访问日志记录模式,不包含cookie。使用这样的东西:
pattern="%t %H request:%{SESSIONID}r %m %U %s %q %r"
而不是
pattern="%t %H cookie:%{SESSIONID}c request:%{SESSIONID}r %m %U %s %q %r"
在server.xml中。
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>