These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How do you get hibernate's logging to work with log4j?
PostPosted: Sun Sep 20, 2009 3:53 am 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
Hi, I just upgraded from 3.2.6 to 3.3.1. I had some conflicts of packages, and ended up having to upgrade to the following dependancies to get everything to work:

Code:
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.6</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.6</version>
        </dependency>


Now in IntelliJ IDEA, I get two loggers going at the same time... Spring is using the same logger as before in a black font... and now all the Hibernate messages (validator, core, etc.) is in a burgundy colour. The weird thing is that the output no longer responds to my log4j settings in log4j.properties :(

Can anyone enlighten me as to what happened? Is slf4j using another logger now? I know next to nothing about slf4j, so any advice on how to stop this from happening would be fantastic if you already know. At this moment, I can't spend the 3 hours it might take someone of my ignorance to fix it ;(

Thanks


Top
 Profile  
 
 Post subject: Re: How do you get hibernate's logging to work with log4j?
PostPosted: Sun Sep 20, 2009 4:29 am 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
Okay, I'm convinced my log4j files aren't even being read anymore. They used to be... like before I upgraded some jar files. now rootLogger=OFF doesn't work at all. It must be getting overrided somehow... OR log4j isn't being used. I dunno how to tell if another log system is being used. Not a clue.


Top
 Profile  
 
 Post subject: Re: How do you get hibernate's logging to work with log4j?
PostPosted: Sun Sep 20, 2009 5:08 am 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
Okay, I'm positive slf4j has hijack my original settings. Grrrrrrrr.

I made a test logger like this:
Code:
   static Logger logger = org.slf4j.LoggerFactory.getLogger( JobManager.class );


And when I log to it, sure enough, it looks exactly like the other logging information that is being thrown at the screen.

What logger is this?
Code:
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.3.1.GA
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: myproject.domain.user.UserAccount -> user_account
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.HbmBinder bindSubclass
INFO: Mapping subclass: myproject.domain.jobseeker.JobSeeker -> user_account
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.HbmBinder bindSubclass
INFO: Mapping subclass: myproject.domain.employer.EmployerUser -> user_account
Sep 20, 2009 5:07:16 AM org.hibernate.cfg.HbmBinder bindSubclass
.......


Top
 Profile  
 
 Post subject: Re: How do you get hibernate's logging to work with log4j?
PostPosted: Sun Sep 20, 2009 5:14 am 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
YES!

Solution:
Code:
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


Each that Spring! :/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.