我的项目使用log4j,但这似乎是通过使用java.util.logging来阻止的。 java信息: java版" 1.8.0_121" Java(TM)SE运行时环境(版本1.8.0_121-b13) Java HotSpot(TM)64位服务器VM(版本25.121-b13,混合模式)
服务器是tomcat。
Jstack日志如下:
"http-nio-192.168.0.94-8443-exec-316" #378 daemon prio=5 os_prio=0 tid=0x00007f96d4f42800 nid=0x3466 waiting for monitor entry [0x00007f96c753d000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.util.logging.SimpleFormatter.format(SimpleFormatter.java)
- waiting to lock <0x00000006c53cdae0> (a java.util.logging.SimpleFormatter)
at org.apache.juli.FileHandler.publish(FileHandler.java:197)
at java.util.logging.Logger.log(Logger.java:738)
at java.util.logging.Logger.doLog(Logger.java:765)
at java.util.logging.Logger.log(Logger.java:788)
at org.restlet.engine.log.LogFilter.afterHandle(LogFilter.java:106)
at org.restlet.routing.Filter.handle(Filter.java:208)
at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:211)
at org.restlet.Component.handle(Component.java:406)
at org.restlet.Server.handle(Server.java:516)
at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:72)
at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:152)
at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1118)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.xxx.xxx.web.Filter.xxxxxxx.doFilter(SGRequestCheck.java:129)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.xxx.trace.http.servlet.filter.BraveServletFilter.doFilter(BraveServletFilter.java:165)
at com.xxx.trace.http.servlet.filter.TraceServletFilter.doFilter(TraceServletFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1756)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1715)
- locked <0x00000006c8a84a70> (a org.apache.tomcat.util.net.SecureNioChannel)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Locked ownable synchronizers:
- <0x00000006c9f790b0> (a java.util.concurrent.ThreadPoolExecutor$Worker)
答案 0 :(得分:0)
阻塞状态并不总是意味着发生了不好的事情,它只是表示某个线程正在等待另一个线程释放其锁定以获取监视器锁定。在您的情况下,多个线程共享SimpleFormatter
类的同一实例,该实例在调用format
方法时获得一个锁。
public synchronized String format(LogRecord record)