parush / elmah

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

ApplicationName is empty when you log an error from Application_End #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
log something in

    void Application_End(object sender, EventArgs e)
    {
       LogException(new ShutDownException("Shutdown"));
    }

My log function is :
        public static void LogException(Exception ex)
        {
            HttpContext context = HttpContext.Current;
            Elmah.ErrorLog.GetDefault(context).Log(new Elmah.Error(ex));
        } 

What is the expected output? What do you see instead?
The "problem" is that ApplicationName is empty (some other fields like 
user and source too) and it seems like you only display exception whith 
non empty ApplicationName. The exception is in the table but is not 
displayed in elmah.axd

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

Please provide any additional information below.

Original issue reported on code.google.com by kni...@gmail.com on 5 Mar 2008 at 12:35

GoogleCodeExporter commented 9 years ago
The behavior is as expected. The problem is that HttpContext is unavailable 
(null) 
at the time of shutdown and during Application_End. When you don't set the 
application name explicitly, ELMAH relies on the HttpContext to infer the 
application name automatically. However, since there is no context, the 
application 
cannot be inferred and therefore the error gets logged with an empty 
application 
name. Finally, as you guessed, when you try to view the error log next time, 
the 
errors logged during Application_End are filtered out. To get around this 
problem, 
you can set the application name explicitly in the configuration file by adding 
the 
applicationName attribute to the errorLog element of ELMAH. I'm marking this 
issue 
as invalid unless it can further identified as a bug.

Original comment by azizatif on 7 Mar 2008 at 11:32

GoogleCodeExporter commented 9 years ago
I fully understand. Thank you for you comment. It's not a bug you are right. 
Maybe 
it would be nice to add this somewhere in the documentation. Maybe it's there 
already and I did not understand it... Thanks again.

Original comment by kni...@gmail.com on 6 Apr 2008 at 9:28