I just installed ELMAH.MVC (more info here) and was wondering where its data is saved. I read that you can choose to set up database for storage but seems that the default install uses "in memory"? How does it work? If I recycle the app pool or IIS website do I loose all the data? Thanks!
Asked
Active
Viewed 1.4k times
42
-
[This](http://code.google.com/p/elmah/) is a more helpful link for more information. – M.Babcock Feb 18 '12 at 17:45
-
http://code.google.com/p/elmah/ – Adrian Iftode Feb 18 '12 at 17:46
-
1You set most options in web.config/app.config, if you check the example one, you'll see (reasonable) instructions how to set various types of storage up. – Joachim Isaksson Feb 18 '12 at 17:48
2 Answers
37
Yes, by default it uses memory storage. When your application pool is restarted, you loose elmah data. If I remember well, old versions of elmah used App_Data folder for storing xml files...If you want to use database to store logs, just specify connection string in your elmah config section:
<elmah>
...
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahConnectionString"/>
...
</elmah>
You should have ElmahConnectionString in your connectionStrings section, something like this:
<connectionStrings>
<add name="ElmahConnectionString "
connectionString="Initial Catalog=my_database;data source=.\SQLEXPRESS;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
...
</connectionStrings>
Here you can find example web.config file.

Atif Aziz
- 36,108
- 16
- 64
- 74

Aleksandar Vucetic
- 14,715
- 9
- 53
- 56
-
2I'm getting "Could not find stored procedure 'ELMAH_GetErrorsXml'."! Already installed http://nuget.org/packages/elmah.sqlserver but still same problem. Remember I'm using Elmah.MVC on top of Elmah (not sure if it makes a difference). Any help? Thanks! – Joao Leme Feb 19 '12 at 00:52
-
4Got it! response http://stackoverflow.com/a/5380167/1133338 . I had to manually run the sql script to create the table. So I was wondering what nuget.org/packages/elmah.sqlserver did (other than adding an empty connection string to my web.config? – Joao Leme Feb 19 '12 at 01:05
-
1It probably just added errorLog entry to the elmah config...it cannot manipulate your database because it "doesn't know" how to connect to it. – Aleksandar Vucetic Feb 19 '12 at 01:23
4
Read in "Examining the ErrorLog Class" topic, and you will find your answer
Using HTTP Modules and Handlers to Create Pluggable ASP.NET Components

Dot Freelancer
- 4,083
- 3
- 28
- 50