Oracle日志填充" java.lang.Throwable:No Error"?

时间:2017-12-07 21:20:19

标签: java oracle jdbc

我为Oracle连接启用了JDBC日志记录。我希望日志只包含已执行查询的文本,但它填充了以下错误。

有关可能导致此跟踪的内容,我如何修复它,以及/或如何将我的日志记录限制为已执行查询的文本的任何建议?

java.lang.Throwable: No Error
  at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1624)
  at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4347)
  at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:4426)
  at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:4733)
  at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at oracle.ucp.jdbc.proxy.PreparedStatementProxyFactory.invoke(PreparedStatementProxyFactory.java:125)
  at com.sun.proxy.$Proxy60.executeQuery(Unknown Source)
  at com.me.MyClass.doQuery(MyClass.java:56)
  at org.apache.jsp.jsp.secure.b2f.b2flogin_jsp._jspService(b2flogin_jsp.java:686)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
  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)

我的OraceLog.properties

oracle.jdbc.level=CONFIG
oracle.jdbc.handlers=java.util.logging.FileHandler
java.util.logging.FileHandler.level=CONFIG
java.util.logging.FileHandler.count=1
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter

java.util.logging.FileHandler.pattern = /tmp/jdbc.log

修改

在使用JDBC日志记录调试我的应用程序之后,我发现跟踪很有用,因为它指示了SQL语句的代码位置。并且可以使用正则表达式轻松过滤掉它:

  

tail -f /tmp/jdbc.log | grep -v' java.lang。* \ |。 at。'

2 个答案:

答案 0 :(得分:1)

这似乎是跟踪SQL语句(.level=CONFIG和更精细)的已知副作用。有关Enabling Oracle JDBC Driver Debug的评论中对此进行了讨论。最后一篇文章是在2012年。

似乎没有办法禁用堆栈跟踪。

答案 1 :(得分:0)

编写一个java.util.logging.Filter,它对No Error日志消息不执行任何操作,并将其附加到Handler。请注意,不会抛出Throwable。这只是一个获得堆栈跟踪的黑客攻击。

Oracle数据库JDBC日志记录是一种用于调试而非生产的工具。这是一个巨大的性能消耗。我们强烈反对在生产中使用它。我们的经验是,想要查看SQL的客户也希望了解它的来源。这就是堆栈跟踪的原因。