Java 带Hibernate的JBoss EAP 6.4-在日志文件中隐藏特定的Oracle异常
使用Java 带Hibernate的JBoss EAP 6.4-在日志文件中隐藏特定的Oracle异常,java,oracle,hibernate,jboss,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 Se
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());
}
在本例中,通过向
JBoss
日志处理程序添加特定筛选器来解决此问题
<filter-spec value="all(not(match("ORA-13333")), not(match("SQL Error: 13333")))"/>
我希望它能对其他人有用