ASP.NET MVC - Castle ActiveRecord - 显示 SQL 查询
我使用 ASP.NET MVC 和 Castle ActiveRecord 作为我的持久层。
我想知道是否可以显示在我的 MySQL 服务器上执行的 SQL 查询。
我知道可以在 Web 应用程序中使用 Castle XML 配置文件中的“show_sql”属性,但我不知道如何使用 Web 应用程序执行此操作,因为我无权访问控制台。
我想我可以使用 log4net 来做到这一点,但是经过使用 Google 的一些研究后,我还没有找到解决方案。
I'm using ASP.NET MVC with Castle ActiveRecord as my persistance layer.
I want to know if it's possible to show the SQL queries being executed on my MySQL server.
I know it's possible in a Web application using the "show_sql" property in the Castle XML configuration file, but I don't know how to do it using a Web application, since I don't have access to the Console.
I think I can use log4net to do it, but after some research using Google, I haven't been able to come up with a solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的Application_Start中:
然后您的根目录中需要一个log4net.config,如下所示:
这是一个示例应用,您可以用作参考。
In your Application_Start:
Then you need a log4net.config in your root, something like this:
Here's a sample app you can use as reference.
这里有一个关于如何为 ASP.NET 配置 log4net 的教程,对于 MVC 来说都是一样的:
http://www.codeproject.com/KB/aspnet/Log4Net_Configuration.aspx
这里是如何配置NHibernate将SQL输出到log4net
http://www.davesquared.net/2008/ 01/viewing-sql- generated-by-nhibernate.html
Here is a tutorial on how to configure log4net for ASP.NET, it's all the same for MVC:
http://www.codeproject.com/KB/aspnet/Log4Net_Configuration.aspx
And here is how to configure NHibernate to output SQL to log4net
http://www.davesquared.net/2008/01/viewing-sql-generated-by-nhibernate.html