Search code examples
iiselmah

Do Elmah.config updates restart IIS?


This seems like a relatively simple question, but I didn't see it clearly indicated in the documentation I examined. Assuming a typical Elmah usage on a Windows Server 2012/IIS 7 webserver installation, if the Elmah web.config settings are pointed to an Elmah.config file, will altering that file trigger under the running application cause IIS to restart?


Solution

  • While the answer provided by Josh would normally be true, it is not in the case of ELMAH. ELMAH instantiates a new error log implementation every time it is needed, reading the configuration from either web.config or the configSource provided.

    You can do a simple test to prove this. If you configure ELMAH to use an external config file for the errorLog element like this:

    <elmah>
      <errorLog configSource="elmah.config"/>
    </elmah>
    

    and your elmah.config looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
    

    When you start the project and force an error, a new XML file is written to the App_Data folder. Change the logPath like this (without restarting the application):

    <?xml version="1.0" encoding="utf-8"?>
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data2" />
    

    (I changed to App_Data2).

    Force a new error and you will now see ELMAH create the App_Data2 folder on the file system.