ELMAH For Multiple Environments

Written by rsolberg on. Posted in All, Technology

Web applications today, especially in medium to larger sized enterprises will be deployed in multiple environments. This allows the development teams to deploy the web application to an environment to verify changes made and that the application functions as expected before shipping it to production. So when you go to use plugins out there such as ELMAH, how should you go about this?  Out of the box, ELMAH allows you to set a single connection string name within your web.config as shown below. So what do you do when you actually have 3 different connection strings for all the environments that your web application exists in?  As it turns out, this is pretty easy to do because ELMAH is open source.  When you download the ELMAH code, you can include it inside your Visual Studio Solution or create a new solution specifically for ELMAH that you can reference from your web application.
If you’re reading this I’m guessing you don’t need help on how to go about doing that.  If you have specific questions, use the contact me page or the comments below.
With the ELMAH code open, look for the SqlErrorLog.cs file and add the code below.  This essentially allows you to set  the connection string property via your application to handle variations… So suppose this was a real world situation where you have a few different connection strings to manage like this: From your Global.asax.cs you can add a line of code to use the correct ELMAH database…
If you’re looking for more information on this, please contact me and I’d be glad to help.
Be Sociable, Share!

Tags: , ,

Trackback from your site.

Leave a comment

© Copyright RSolberg, 2003 - 2014. All Rights Reserved