We have a Java-based webapp running on JBoss EAP 6.4. We were getting way too many log messages from certain portions of our code, for example, thousands of
15:06:31,400 INFO [stdout] (pool-6-thread-1) Hibernate: select nextval ('hibernate_sequence')
In our presistence.xml, we had:
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.datasource" value="java:jboss/datasources/ourDS"/>
<!-- Scan for annotated classes and Hibernate mapping XML files -->
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"/>
</properties>
Following the advice of this blog, we commented out the show_sql
line, because we want to have finer control of our logging. After doing so, the hibernate logging disappeared, as expected. Next, we tried to turn logging back on, using JBoss's standalone.xml file and setting the level for org.hibernate.SQL
to be INFO
.
<profile>
<subsystem xmlns="urn:jboss:domain:logging:1.5">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="org.hibernate.SQL">
<level name="INFO"/>
</logger>
<logger category="org.jboss.as.config">
<!-- other config omitted -->
</profile>
This doesn't seem to work. None of the original Hibernate log messages appear. Why?
As I've mentioned, ultimately we want to have finer-grained output of our messages, i.e., suppress logging for certain Hibernate persistence operations while enabling it for others. But first I need to figure out the basic problem.
BTW, I've set a breakpoint in the Java debugger to inspect the debug setting.
Logger sqlLogger = Logger.getLogger("org.hibernate.SQL");
Level sqlOrigLogLevel = sqlLogger.getLevel();
It shows INFO
.
Hibernate logs in the org.hibernate.SQL
category at the DEBUG level, your configuration limits it to INFO so they are silenced. You need to lower that level to DEBUG if you want to see the logs.
This not the same thing as hibernate.show_sql
, when that option is enabled it uses the console, not the logger. So it should probably be disabled