If you allow an exception to propagate to the Elmah web module, it will automatically register these exceptions.
However, you can program the log directly in Elmah, there are several ways to do this:
In catch code, you can use code like this in code:
try{....} catch(Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); }
Another way to do this:
Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(ex));
I would, however, port this code to a more general IErrorLogger style interface so that your lower-level code does not need to be heavily dependent on Elmah itself
saret source share