42

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!

harriyott
  • 10,505
  • 10
  • 64
  • 103
Joao Leme
  • 9,598
  • 3
  • 33
  • 47

2 Answers2

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
  • 2
    I'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
  • 4
    Got 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
  • 1
    It 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