To trace parameter values of hibernate SQL statements, a common log4j parametrization looks like that:
<logger name="org.hibernate.SQL">
<level value="debug" />
</logger>
<logger name="org.hibernate.type.descriptor.sql.BasicBinder">
<level value="trace" />
</logger>
This yields log outputs like that:
2019-01-10 00:10:29,349 [main] DEBUG SqlStatementLogger.logStatement(SqlStatementLogger.java:92) - select land0_.fk_land as fk_land1_24_0_ from land land0_ where land0_.fk_land=?
2019-01-10 00:10:29,349 [main] TRACE BasicBinder.bind(BasicBinder.java:65) - binding parameter [1] as [BIGINT] - [27]
This is very useful to analyze how the application path was executed at runtime.
The problem is, that BasicBinder also logs the whole string representation of values of LOB parameters (like byte[]) which is very unuseful:
2019-01-07 13:28:45,466 [wwsservices-catalina-exec-10] TRACE org.hibernate.type.descriptor.sql.BasicBinder: binding parameter [2] as [BLOB] - [[37, 80, 68, 70, 45, 49, 46, 52, ...
The string representation of the whole blob is printed to the log file which is very annoying to me.
Is there a way to suppress / shorten log output of LOB values in Hibernate or log4j while still displaying values of other statement parameters?
Is there a possibility to set maximum log statement size in log4j?