Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elmah setup with SQL Server 2008

Tags:

elmah

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.

like image 727
Nate Pet Avatar asked Sep 18 '12 19:09

Nate Pet


1 Answers

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.

like image 194
Paige Cook Avatar answered Oct 21 '22 04:10

Paige Cook