Thomas-Clark / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
0 stars 0 forks source link

When having no HttpContext, logging error works, mail is sent, but to DB nothing is written... #366

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. In Web app store HttpContext.Current.ApplicationInstance
2. Spawn a background thread and call 
Elmah.ErrorSignal.Get(httpApplicationContext).Raise(e);
3. Unlike in web-context, i only got email, inserting the error into sql DB 
probably failed.

What is the expected output? What do you see instead?
Expected is to log both to DB and send an email. Of couse without server 
variables, since HttpContext must not be alive when background thread finishes.

What version of the product are you using? On what operating system?
1.2

Please provide any additional information below.
See attachment of an email sent on error...

Original issue reported on code.google.com by balazs.h...@gmail.com on 7 Aug 2014 at 3:30

Attachments:

GoogleCodeExporter commented 9 years ago
Just to make it clear, when calling the same method and when HttpContext is 
available, everything is ok.

Original comment by balazs.h...@gmail.com on 7 Aug 2014 at 3:32

GoogleCodeExporter commented 9 years ago
Hi, is there a way to change priority to HIGH/CRITICAL? If elmah is about 
logging and when logging does not occure, then its a CRITICAL bug!

Are there any plans about fixing this issue and releasing a new version of 
elmah? If yes, approx. when will it be issued?

Original comment by balazs.h...@gmail.com on 7 Oct 2014 at 6:54

GoogleCodeExporter commented 9 years ago
This is an unsupported scenario because by-design, HttpApplication is not meant 
to be used by a thread not participating in a request. Stashing it away to use 
from an app-started thread is only asking for trouble. Usually once a request 
ends, the HttpApplication instance is destroyed or reset & returned to a pool 
to be used for a future request.

ErrorSignal relies on HttpApplication so it shouldn't be used outside a 
request. To log to DB, log directly via ErrorLog.GetDefault(null).Log(…).

Original comment by azizatif on 7 Oct 2014 at 7:33