-->
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.  [ 3 posts ] 
Author Message
 Post subject: Separating log4net log files
PostPosted: Wed Mar 15, 2006 5:50 am 
Newbie

Joined: Wed Mar 15, 2006 5:44 am
Posts: 4
Hi,

My application uses NHibernate and log4net for my specific application logging while NHibernate also uses log4net.

My question: How can I configure log4net and NHibernate to use seperate files for NHibernate logging and application logging?

I've seen some posts but they always suggest to set levelrange filters to do this. That way eg errors would be NHibernate and info's would be application. Ofcourse this can never be the idea of logging. I'm looking for an NHibernate setting that tells NHibernate which appender to use.

If not possible, can someone tell me how to disable logging in NHibernate?

Thanks
Koen


Top
 Profile  
 
 Post subject: Re: Separating log4net log files
PostPosted: Wed Mar 15, 2006 9:40 am 
Beginner
Beginner

Joined: Fri Nov 11, 2005 1:04 pm
Posts: 22
Koevoeter wrote:
Hi,

My application uses NHibernate and log4net for my specific application logging while NHibernate also uses log4net.

My question: How can I configure log4net and NHibernate to use seperate files for NHibernate logging and application logging?

I've seen some posts but they always suggest to set levelrange filters to do this. That way eg errors would be NHibernate and info's would be application. Ofcourse this can never be the idea of logging. I'm looking for an NHibernate setting that tells NHibernate which appender to use.

If not possible, can someone tell me how to disable logging in NHibernate?

Thanks
Koen

To disable NHibernate Logging altogether, explicitly set it's log level to none.
Code:
<logger name="NHibernate">
  <level value="NONE"/>
</logger>



To have nHibernate log to a different file give it it's own appender by using the appender-ref element.
Code:
   
<logger name="NHibernate">
  <level value="DEBUG"/>
  <appender-ref ref="nHibernateAppender"/>
</logger>


Of course you need to set up a separate appender for this to work
Code:
<appender name="mainApp" type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="applog.txt" />
<param name="AppendToFile" value="false" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy.MM.dd" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
   <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
  </layout>
</appender>
<appender name="nHibernateAppender" type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="nhibernatelog.txt" />
<param name="AppendToFile" value="false" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy.MM.dd" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
   <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
  </layout>
</appender>



And that should do it for you.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 10:17 am 
Newbie

Joined: Wed Mar 15, 2006 5:44 am
Posts: 4
Thanx,

I did not know the crucial concept of loggers...


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