-->
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.  [ 5 posts ] 
Author Message
 Post subject: log4net for NHibernate and my custom logging
PostPosted: Tue Jul 26, 2005 4:44 pm 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
I followed this post (and the links therein)

http://nhibernate.sourceforge.net/forum ... ht=log4net

and have a few questions. First, I want to disable DEBUG for NHibernate only, since it is crippling the server. I need to output DEBUG for my class library logging code.

To accomplish this I have configured log4net in the web.config with 1 appender, ADONetAppender and 2 loggers:

Code:
<root>
      <level value="DEBUG" />
      <appender-ref ref="ADONetAppender" />
</root>
   
<logger name="NHibernate" additivity="false">
   <level value="WARN" />
   <appender-ref ref="ADONetAppender" />
</logger>
   
<logger name="Foundation" additivity="false">
   <level value="DEBUG" />
   <appender-ref ref="ADONetAppender" />
</logger>


How can I get NHibernate to USE the logger specified above and not the root? Also, how do I get MY logging to use the 2nd logger there?

I have not been able to see any examples of this yet online.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 7:44 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Here's a section of our config:
Code:
<root>
    <level value="ALL" />
    <appender-ref ref="RollingFileAppender" />
    <appender-ref ref="ADONetAppender_Oracle" />
    <appender-ref ref="SMTPAppender" />
</root>
<logger name="NHibernate">
    <level value="ERROR" />
</logger>
<logger name="NHibernate.Loader.Loader">
    <level value="INFO" />
</logger>

The NHibernate.Loader.Loader logs the SQL sent to the server. Otherwise, the only messages from NHibernate are errors or fatals.

HTH


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 10:52 am 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
I actually did something very similar, except I wasn't sure if it was going to work.

If I have a logger named NHibernate, how do I configure nhibernate to use that logger instead of root?

I have my code using a different logger, so I can set the level on that to DEBUG, so for right now it's working, but I'm not sure if NHibernate is using the root logger or the "NHibernate" logger.

NHibernate.Loader.Loader ? that will output only SQL statements?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 5:32 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
The logger name is matched against the class name you use in
Code:
LogManager.GetLogger( Type or string )


So, the NHibernate logger applies to all (full) class names that start with NHibernate - the whole NHibernate assembly.

In my example, the logs generated by the NHibernate.Loader.Loader(.*) class(es) are logged if their log level is INFO or higher. There are DEBUG logs sent out by that class, but I am ignoring them by specifying INFO.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 12:25 pm 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
That's exactly what I needed to know, thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.