views:

39

answers:

1

Odd one this.

I am using NHibernate with one website. I have configured log4net to show me all SQL and and errors in the trace. It all works swimmingly.

I start using NHibernate in the other website - same solution, built on top of same class libraries. I copy the configuration data in web.config from one website to the other:

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<log4net>
    <appender name="AspNetTraceAppender" type="log4net.Appender.AspNetTraceAppender" >
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <logger name="NHibernate.SQL" additivity="false">
      <level value="DEBUG" />
      <appender-ref ref="AspNetTraceAppender" />
    </logger>
    <root>
      <level value="ERROR"/>
      <appender-ref ref="AspNetTraceAppender"/>
    </root>
  </log4net>

Obviously the new website also has a reference to log4net.dll.

But in the new website, I get no NHibernate output in the trace!

To the best of my knowledge, with log4net you just reference the dll, set up the config and off you go.

Can anyone think what I might be missing?

Thanks

David

+2  A: 

Looks like you're forgetting to initialize it.

Take a look at the comment section of this post:

Logging NHibernate SQL with log4net in ASP.NET

Leniel Macaferi
You're absolutely right, and I need shooting. Thank you.
David