开发者

log4net for NHibernate not writing anything into ASP.NET trace

开发者 https://www.devze.com 2023-01-09 03:41 出处:网络
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.

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开发者_如何学C 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消