Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning off net.sf.ehcache and org.hibernate DEBUG logging

Tags:

spring

ehcache

I am getting a host of DEBUG messages from net.sf.ehcache and org.hibernate in my Spring (version 5.2.5.RELEASE) application. I am using version 5.2.10.Final of hibernate-ehcache. The messages look like this:

16:20:12.910 [RMI TCP Connection(3)-127.0.0.1] DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl - Mocking Operation Statistic: XA_COMMIT
16:20:12.910 [RMI TCP Connection(3)-127.0.0.1] DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl - Mocking Operation Statistic: XA_ROLLBACK
16:20:12.910 [RMI TCP Connection(3)-127.0.0.1] DEBUG net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl - Mocking Operation Statistic: XA_RECOVERY

and also many like this:

1:14:39.284 [http-nio-8080-exec-3] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Done materializing entity [com.acme.MyBean#145]

I've tried to turn them down by using this in log4j.xml

<logger name="net.sf.ehcache">
    <level value="WARN"/>
</logger>

I've also tried this in application.properties:

logging.level.org.springframework.web=WARNING
logging.level.org.hibernate=ERROR
logging.level.org.springframework.cache=WARNING

But neither of these changes filters out the DEBUG messages.

Here is the ehcache configuration as defined in spring-config.xml:

<bean id="readOnlyDatabaseSessionFactory"
    class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">
                org.hibernate.dialect.SQLServerDialect
            </prop>
            <prop key="hibernate.show_sql">${hibernate.debug}</prop>
            <prop key="hibernate.format_sql">${hibernate.debug}</prop>
            <prop key="hibernate.use_sql_comments">${hibernate.debug}</prop>
            <prop key="hibernate.cache.region.factory_class">
                org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
            </prop>
            <prop key="net.sf.ehcache.configurationResourceName">
                ehcache.xml
            </prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.default_batch_fetch_size">100</prop>
        </props>
    </property>
    <property name="dataSource" ref="readOnlyDataSource"/>
</bean>

I have the following settings in application.properties:

# logging for hibernate
logging.level.org.hibernate.SQL=warn
logging.level.org.hibernate.stat=warn
logging.level.org.hibernate.type=warn

logging.level.org.springframework.web=WARN
logging.level.org.hibernate=ERROR
logging.level.org.springframework.cache=WARN

logging.level.root=WARN
logging.level.net.sf.ehcache=WARN

spring.jpa.properties.hibernate.generate_statistics=false

How do I turn off DEBUG messages for net.sf.ehcache and org.hibernate?

like image 496
Paul Reiners Avatar asked Dec 01 '25 23:12

Paul Reiners


1 Answers

If you want to turn off the logging on a specific package you should use the value off. This will work both on package and class level like:

logging.level.org.hibernate.SQL=OFF

com.yourproject.util.SomeUtilsClass=OFF

Normally logging.level.net.sf.ehcache=WARN should work, but can you try:

logging.level.net.sf.ehcache.statistics.extended=WARN

If you're running a junit test you should update/create different config for that because by default junit will use DEBUG as the root log level where when you launch your springboot app it will use by default INFO and what you customized in your application.properties.

like image 191
Oussama BEN MAHMOUD Avatar answered Dec 04 '25 18:12

Oussama BEN MAHMOUD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!