Jackie
Jackie

Reputation: 23607

Hibernate not logging to Log4J

I have a tomcat app using hibernate. When I go into the WEB-INF and change the log4j.properties to the following...

log4j.logger.net.sf.hibernate.SQL=trace

But I am not seeing anything in the log file I am using.

log4j.rootLogger=debug, stdout
....
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

Logging seems to work fine for my own app.

Any ideas?

Upvotes: 1

Views: 1901

Answers (2)

cherouvim
cherouvim

Reputation: 31928

Try the following because hibernate is no longer under a net.sf package hierarchy:

log4j.logger.org.hibernate.SQL=trace

Upvotes: 0

esaj
esaj

Reputation: 16035

Not sure on this, but I think newer Hibernate-versions might use slf4j instead of log4j. You can get past this by using a slf4j-log4j -bridge. If you're using Maven, the dependency is along the lines of

    <!-- slf4j -> log4j bridge (some libraries use slf4j) -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.6</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

Modify versions as necessary.

Upvotes: 6

Related Questions