views:

186

answers:

3

I spawn a thread on Application_Start and would like to log exceptions. There is not Context/HttpContext/HttpContext.Current, so how might i get it to log?

ATM it does not catch any exception in my threads and if i write ErrorSignal.FromCurrentContext().Raise(ex); i get an error about context cannot be null.

Maybe i can create a dummy HttpContext but somehow i dont think that will work well.

-edit- i tried ErrorSignal.Get(new HttpApplication()).Raise(ex); and it doesnt seem to pick up that exception.

+1  A: 

I am in the same situation. No answers from anyone?

+1  A: 

Make sure you set your application name in web.config

and then

ErrorLog.GetDefault(null).Log(new Error(error));

will work

Brendan Carey
Thank you! I appreciated it very much!
acidzombie24
A: 

I added a solution to: http://stackoverflow.com/questions/841451/using-elmah-in-a-console-application that adds ability to send email, tweets and filter in addition to logging.

Brian Chance