NHibernate 的 log4net 未将任何内容写入 ASP.NET 跟踪
奇怪的是这个。
我正在一个网站上使用 NHibernate。我已配置 log4net 以显示跟踪中的所有 SQL 和错误。一切都进展顺利。
我开始在另一个网站中使用 NHibernate - 相同的解决方案,构建在相同的类库之上。我将 web.config 中的配置数据从一个网站复制到另一个网站:
<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>
显然新网站也引用了 log4net.dll。
但在新网站中,我在跟踪中没有得到 NHibernate 输出!
据我所知,使用 log4net,您只需引用 dll,设置配置即可。
谁能想到我可能会错过什么?
谢谢
大卫
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您忘记了初始化它。
看一下这篇文章的评论部分:
日志记录ASP.NET 中的 NHibernate SQL 与 log4net
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