I am trying to configure elmah with sql server. The configuration I see are of this form
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
...
}
private static void InjectsAuthElements(IServiceCollection services)
{
...
services.AddElmah<SqlErrorLog>(options =>
{
options.Path = "ElmahNewNameForSecurity.axd";
options.OnPermissionCheck = context => context.User.Identity.IsAuthenticated && context.User.IsInRole("Admin");
options.ConnectionString = "MyConnectionString";
});
}
}
I want to replace MyConnectionString by something like Configuration.GetConnectionString("Default").
Just add an
IConfigurationinterface as a second parameter to the method and pass theConfigurationwhen you call the method.