I'd like to configure ELMAH for an ASP.NET MVC site entirely in code. This includes registering the module, setting the logging provider and settings, and filtering exceptions.
The only part I've managed to do so far is filter exceptions. Has anyone else figured out how to do this? I'd really like to avoid cluttering up my config file with settings that won't ever change.
Link to the original bug/feature in google code.
Link to a google groups discussion giving basic sample code for implementing the service container.
static ServiceProviderQueryHandler
CreateServiceProviderQueryHandler(IServiceProvider sp) {
return context => {
var container = new ServiceContainer(sp);
var log = new SqlErrorLog("…connection string…");
container.AddService(typeof(ErrorLog), log);
return container;
}
}
I think you can do that using version 1.2 beta http://code.google.com/p/elmah/issues/list?&q=label%3AMilestone-Release1.2+status=Fixed&can=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With