禁用 NHibernate 日志记录
我有一个空 app.config 文件,但我仍然收到 NHibernate 调试日志
NHibernate: SELECT this_.LogID as LogID71_0_, this_.Level as Level71_0_, this_.Message as Message71_0_, this_.EventTime as EventTime71_0_, this_.Component as ...
我尝试添加具有错误日志级别的 log4net 配置,但没有用。我怎样才能停止这些日志消息?
我感到困惑的是,如果我有一个空的 app.config ,为什么这些会首先出现。我必须将其配置为不打印这些消息对我来说没有意义 - 默认值应该关闭。难道是我的代码以某种方式以编程方式设置它们?我应该寻找什么?
I have an empty app.config file, but I still get NHibernate debug logs
NHibernate: SELECT this_.LogID as LogID71_0_, this_.Level as Level71_0_, this_.Message as Message71_0_, this_.EventTime as EventTime71_0_, this_.Component as ...
I tried adding a log4net configuration with an ERROR log level, but no use. How can I stop these log messages?
The thing I'm puzzled about is why do these appear in the first place if I have an empty app.config to being with. It doesn't make sense to me that I have to configure it not to print these messaages - the default should be off. Could it be my code is setting them on programatically somehow? What should I look for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
配置 Log4Net 以与 NHibernate 一起使用可能会有所帮助。
您需要拥有这两个记录器:
Configure Log4Net for use with NHibernate may be helpful.
You need to have both these loggers:
删除
.ShowSql()
对我有用Removing the
.ShowSql()
worked for me问题出在“我的代码”中的某个地方。我们手动构建 NHibernate 配置(将 show_sql 标志设置为 true)。
The problem was somewhere in "my code". We build the NHibernate configuration manually (setting the show_sql flag to true).
NHibernate 日志对我没有多大帮助...我更喜欢这些设置:
The NHibernate logs don't help me much... I like these settings better:
您想要禁用 NHibernate 级别还是 Log4Net 级别的日志记录吗?
我通过将“show_sql”变量设置为 false 来执行前者。我现在正在用 C# 以编程方式执行此操作,但我认为这也很容易放入 XML 配置文件中。
Do you want to disable the logging at the NHibernate level or the Log4Net level?
I'm doing the former by setting "show_sql" variable to false. I'm doing this programmatically in C# right now, but I assume this would be easy to put in an XML configuration file as well.
对我来说这是 NUnit 问题。在 TeamCity 中运行测试时会发生额外的日志记录,该测试必须使用不同版本的 nunit
For me it was the NUnit problem. The extra logging was happening when running the tests in TeamCity which must have been using a different version of nunit
您使用的是 NUnit 2.4.6 吗?我读了此昨天的博客文章说这个版本的 NUnit 将 log4net 设置为使用 DEBUG 级别日志记录,这也影响了 NHibernate。
如果它不是 NUnit 并且不是你,我会检查它是否是你正在使用的其他第三方库。
编辑
再想一想,我不认为输出与 log4net 有关。格式看起来更像是“show_sql”控制的输出。我会检查两件事:
1. 如果正确的(show_sql=false 的)hibernate.config 被复制到您的执行目录。
2. 如果未在代码中手动覆盖 show_sql 配置属性。
Are you using NUnit 2.4.6? I read this blog post yesterday which says that this version of NUnit sets log4net to use DEBUG level logging, effecting NHibernate as well.
if it's not NUnit and it's not you, I would check if it's some other 3rd party library that you're using.
EDIT
On second thought, I don't think that the output has something to do with log4net. the format looks more like the "show_sql" controlled output. I would check two things:
1. If the correct (the one with the show_sql=false) hibernate.config is copied to your execution directory.
2. If the show_sql configuration property is not overridden manually in your code.