.net - Changing ELMAH database in code -


i have several websites have separate elmah databases. have 1 separate website view these databases.

i've created new asp.net mvc 4 website purpose. i've added nuget package "elmah.mvc" , added following web.config:

<connectionstrings>     <add name="elmah.sql" connectionstring="..." /> </connectionstrings> <elmah>     <errorlog type="elmah.sqlerrorlog" connectionstringname="elmah.sql" /> </elmah> 

this works fine going single database. can switch database changing connectionstring, want able switch database code. there way that?

elmah has class customize error log. need implementing class like

public class yourerrorlog : sqlerrorlog {     public override string connectionstring     {                 {             //return connection string want         }     } } 

in implementation, can read connection string want. can tell elmah know errorlog by

<elmah>     <errorlog type="yourassembly.yourerrorlog, yourassembly" connectionstringname="elmah-sqlserver" /> </elmah> 

you can see details here

i found out 1 example in case here

hope help.


Comments