带有Hibernate的JBoss EAP 6.4-在日志文件中隐藏特定的Oracle异常

时间:2018-09-25 12:24:45

标签: java oracle hibernate jboss

使用PersistenceException-> SQLException-> getErrorCode(),我在日志中隐藏了一个特定的Oracle错误。问题是,在我的server.log中,我仍然发现以下行:

WARN  25 Sep 2018 12:14:47,121 - id  - org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ms 5829302 SQL Error: 13333, SQLState: 72000
ERROR 25 Sep 2018 12:14:47,121 - id  - org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ms 5829302 ORA-13333: invalid LRS measure
ORA-06512: at "MDSYS.SDO_LRS", line 3149
ORA-06512: at line 1

不是我专门记录的。

这是我的代码:

try {
 try {
  //business stuff
 } catch (PersistenceException persEx) {
  if (persEx.getCause() != null && persEx.getCause() instanceof GenericJDBCException) {
   GenericJDBCException jdbcEx = (GenericJDBCException) persEx.getCause();
   SQLException sqlEx = (SQLException) jdbcEx.getCause();
   if (sqlEx.getErrorCode() == 13333) {
    //handling ORA-13333: invalid LRS measure as an info
    log.info("Possible invalid LRS measure");
   } else {
    throw persEx; // do not swallow unhandled exceptions
   }
  } else {
   throw persEx; // do not swallow unhandled exceptions
  }
 } catch (Exception e) {
  log.error("Other exception:" + e.getMessage());
 }
} catch (Exception e) {
 log.error("Exception to log:" + e.getMessage());
}

1 个答案:

答案 0 :(得分:1)

在这种情况下,通过向JBoss日志处理程序中添加特定的过滤器来解决

<filter-spec value="all(not(match(&quot;ORA-13333&quot;)), not(match(&quot;SQL Error: 13333&quot;)))"/>

我希望它对其他人有用。