why do you need Log4Net for nhibernate?

≡放荡痞女 提交于 2021-01-28 02:09:30

问题


I am going to build my application using asp.net mvc3 and nhibernate 3.2. I decided to use Elmah to log all the error messages.

I remember nhibernate supports log4net and use it to log all queries. If I dont care about outputting the queries to the log file, I can use nhibernate profiler to do that, what other reasons will stop me swtiching from log4net to Elmah?


回答1:


Well, whether you actively use the logging abilities of NHibernate or not, the NHibernate library's code has dependencies on log4net, and so you will need to have the log4net DLL available to NHibernate in order to load the NHibernate DLL. You can only get around this by downloading the NHibernate source and modifying it to remove uses of log4net (either stripping out the logging capability entirely or replacing it with Elmah).

This is why, in general, you must be careful what libraries you use to develop your own code, because the more you use, the more your app will need, even if the user never actually causes your app to execute a single line of the referenced code.




回答2:


In NHibernate 3+ tight dependency on log4net is broken. You can easily use it with nlog for example.



来源:https://stackoverflow.com/questions/9932425/why-do-you-need-log4net-for-nhibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!