如何让 ELMAH 记录到 MySQL?
我们已将 ELMAH 与 ASP.NET MVC 3 集成,作为记录应用程序错误的一种方式。但是,我们还没有持久化日志。为此,我们希望将 ELMAH 的日志条目存储在 MySQL 中,因为我们已经将此数据库服务器的实例用于其他目的。
我们如何配置 ELMAH 以使其日志与 MySQL 保持一致?
We have integrated ELMAH with ASP.NET MVC 3, as a way to log application errors. However, we do not yet persist the log. To this end, we'd like to store ELMAH's log entries in MySQL, as we're already using an instance of this database server for other purposes.
How do we configure ELMAH so that it persists its log with MySQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 MySQL 上安装 NuGet 包
ELMAH
您必须对其进行配置。来自Elmah.MySql.txt,它是包的一部分。
请注意,为了完成 ELMAH.MySql 的安装,您必须执行以下操作:
更多信息
You can install the NuGet package
ELMAH on MySQL
You have to configure that. from Elmah.MySql.txt which is part of the package.
Please note that in order to complete the installation of ELMAH.MySql you will have to do the following:
More Information
这就是我配置 elmah 写入 MySQL 的方式。在 Visual Studio 中...
这两个安装对 web.config 文件进行了一些更改,这些是要查找的相关部分:
这需要一个新的连接字符串... elmah 已添加对于我的模板,我只需要输入正确的凭据:
如果您使用的是 EntityFramework,请确保 EntityFramework 提供程序是正确的,
并且 DbProviderFactories 是正确的
这就是我所要做的让它运行起来。
注意:需要注意的一件事是在上面的连接字符串中使用小写字符作为数据库名称,因为 MySQL 数据库名称是小写的...它最初对我来说是大写的,但后来它坏了,我不得不更换它。
This is how I have configured elmah to write to MySQL. In Visual Studio...
These two installation make some changes to the web.config file, these are the relevant sections to look for:
This required a new connection string... elmah already added the template for me, I just needed to put the correct credentials in:
Make sure EntityFramework provider is correct, if you are using EntityFramework
and DbProviderFactories are correct
And that's all I had to do to get it running.
Note: One thing to watch for is to use lowercase characters for your DB name, in the above connection string, as MySQL DB names are in lowercase... It did work for me initially with uppercase but then it broke and I had to change it.