Tweak hibernate logging level for one specific JDBC error
<p>Environment: Hibernate 4.2.6</p>

<p>Scenario: hibernate logs “ERROR” for a specific "unique constraint PK_XXX  violated" sql exception. 
However due to our specific multiple instance deployment scenario, we need to tweak this to “INFO” level for this specific "unique constraint PK_XXX  violated" sql exception. (So it does not confuse IT folks). </p>

<p>In other words, technically it is "ERROR", but it is "INFO" from business perspective. </p>

<p>Currently:</p>

<p><code>2016.01.19 13.20.14,299 [ ERROR ][  ][  ][  ] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - logExceptions() ORA-00001: unique constraint (PK_LOCKINFO) violated</code></p>

<p>Desired: </p>

<p><code>2016.01.19 13.20.14,299 [ INFO ][  ][  ][  ] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - logExceptions() ORA-00001: unique constraint (PK_LOCKINFO) violated</code></p>

<p>What is the easiest way to go forward? Options I could think of: </p>

<ol>
<li>Modify hibernate internal class  "org.hibernate.engine.jdbc.spi.SqlExceptionHelper" , then recompile the “hibernate” jar</li>
</ol>

<p>The specific customization is: in case of "unique constraint  PK_LOCKINFO violated" sql exception, log it as "INFO" level instead of "ERROR" level.  But any other sql exceptions should still be logged as "ERROR" level. 
This option poses a challenge as we go forward.  We will have to do it every time hibernate upgrades.   </p>

<ol start="2">
<li><p>have a class to extend &amp; customize hibernate class  "org.hibernate.engine.jdbc.spi.SqlExceptionHelper" in our own codebase
This way we do not have to compile a “hibernate” jar. Is this possible? </p></li>
<li><p>Add a after-the-fact-listener in our code which scans through "log" constantly, then do something about it</p></li>
</ol>

<p>Not sure if I like option #3 or not. Seems too awkward. </p>

<p>Any other options? </p>