I am using MVC 3 with SQL Server 2008 R2 DB.
I installed elmah 1.2.2 and SQL Server script.
Might anybody have some detailed information on how to setup Elmah with SQL Server 2008.
I checked online but could not find detailed information.
Since you have already run the SQL Server setup script and installed Elmah in your MVC application, you should just need to add the following to your web.config to have Elmah send its logs to your sql server instance.
<elmah>
...
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="<definedConnectionString>"
applicationName="MyAppName"/>
...
</elmah>
Keeping in mind that you will need to replace "<definedConnectionString>"
with the name of the connection string that points to your SQl 2008 instance from your <connectionStrings>
section of your web.config.
I would also recommend reading through the following 5 part series: Logging Errors with ELMAH and MVC 3, it contains a lot of great recommendations for using ELMAH with MVC. Also you might consider using installing the Elmah.MVC NuGet Package to change the default behavior of Elmah within an MVC application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With