I want to integrate ELMAH into an existing ASP.NET application to further support error research and can help with the connection string. We use a single web.config file for all or our environments in which the application is deployed, and at runtime the application decides which environment it is located in, usually based on the URL.
This is what we will like the standard block ...
<connectionStrings>
<add name="TESTAppDB" connectionString="Data Source=SQL-T-APPNAME.COMPANY.COM;Initial Catalog=APPNAME;User ID=USER;Password=THEPASS" providerName="System.Data.SqlClient"/>
<add name="CERTAppDB" connectionString="Data Source=SQL-C-APPNAME.COMPANY.COM;Initial Catalog=APPNAME;User ID=USER;Password=THEPASS" providerName="System.Data.SqlClient"/>
<add name="PRODAppDB" connectionString="Data Source=SQL-P-APPNAME.COMPANY.COM;Initial Catalog=APPNAME;User ID=USER;Password=THEPASS" providerName="System.Data.SqlClient"/>
</connectionStrings>
With Elmah, it seems you just need to specify the connection string name, but how can I do this dynamically at runtime? For example, if I test, then I want this:
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="TESTAppDB"/>
</elmah>
but if I'm in PROD:
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="PRODAppDB"/>
</elmah>
- , . , ELMAH Sql...
- . , , TEST, CERT. CERT PROD. - , ...