Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable hibernate 4 output with log4j2?

I'm having the follwoing log4j2.xml configuration. I saved it in the the root of the resource folder.

I don't get to manage to get rid of the INFO stdout hibernate output. e.g.

06:17:01,835 INFO  [stdout] (ServerService Thread Pool -- 52)     insert into hibernate_sequence values ( 1 )

What is wrong with my configuration and/or what is missing?

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="com.mycode" level="trace" additivity="false">
            <AppenderRef ref="Console"/>
        </Logger>
        <Logger name="org.hibernate" level="warn" additivity="false">
            <AppenderRef ref="Console"/>
        </Logger>
        <Root level="warn">
            <AppenderRef ref="Console" />
        </Root>
    </Loggers>
</Configuration>

I have these libraries attached to my project.

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.0.2</version>
        </dependency>

And I'm using this API version of JPA/Hibernate 4.

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <scope>provided</scope>
        </dependency>
like image 271
feder Avatar asked Aug 26 '14 04:08

feder


1 Answers

I was facing the same issue and turning Log level Off is working for me:

 <logger name="org.hibernate" level="OFF" additivity="false">
        ...
</logger>
like image 86
Lokesh Guru Avatar answered Oct 22 '22 09:10

Lokesh Guru