Logging Works Locally But Fails In Production

359 views
Skip to first unread message

Zian Choy

unread,
Aug 27, 2009, 7:37:31 PM8/27/09
to el...@googlegroups.com

I just started using Elmah with .NET 3.5 and ASP .NET MVC Version 1. I develop in Windows XP and the server is Windows Server 2003. I’ve searched all over the place and found no help so I’m presenting the case to the mailing list.

 

Everything works perfectly when I run things locally. The friendly error page comes up, ELMAH records all the exception details, and the error’s information shows up in the ELMAH Error Log.

 

However, when I copy the files to the server and go to the same crash-inducing page (division by zero exception), nothing is logged. I see the friendly error page but ELMAH tells me that nothing went wrong. In addition, the error gets sent to the Event Log.

 

I’ve attached a copy of the Web.config.

 

Any advice will be very much appreciated.

 

Sincerely,

Zian Choy

Web.config

James_2JS

unread,
Aug 28, 2009, 4:44:00 AM8/28/09
to ELMAH
Hi there,

Taking a quick look at your config file you've got the <elmah>
configuration in the wrong place.
You've put it in the <system.webServer> section when it should be in
<system.web>.
<system.webServer> is used for IIS7 config.

Take a look at the sample web.config here
http://code.google.com/p/elmah/source/browse/trunk/samples/web.config
and you should be able to see where you've gone wrong!!

Cheers,

James
>  Web.config
> 17KViewDownload

Zian Choy

unread,
Aug 28, 2009, 11:33:13 AM8/28/09
to el...@googlegroups.com
Actually, it's not in the system.webServer or system.web sections. It's
outside of both of them, just like the sample web.config.

I've reformatted my web.config so that it is clearer.
Sincerely,
Zian Choy
Web.config

James_2JS

unread,
Aug 28, 2009, 11:49:13 AM8/28/09
to ELMAH
Hi again!

> Actually, it's not in the system.webServer or system.web sections. It's
> outside of both of them, just like the sample web.config.

Sorry... you're right.. it shouldn't be in <system.web> either...
DOH!!

What I think you are missing though is adding the httpHandler and the
httpModule in the <system.webServer> declaration.
Locally you are running under Cassini or IIS6.
On the server I guess you are running IIS7.

If I'm right you are missing the following (taken from
http://code.google.com/p/elmah/source/browse/trunk/samples/web.config):
(Obviously you will need to remove the lines that are not applicable
to your configuration).

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"
preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule,
Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"
preCondition="managedHandler" />
<add name="ErrorTweet" type="Elmah.ErrorTweetModule,
Elmah" preCondition="managedHandler" />
</modules>
<handlers>
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD"
type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /
>
</handlers>
</system.webServer>

Zian Choy

unread,
Aug 28, 2009, 8:47:12 PM8/28/09
to el...@googlegroups.com
Unfortunately, the server runs Windows Server 2003, which can only run IIS6.

Curioser and curioser...
Zian Choy

-----Original Message-----
From: el...@googlegroups.com [mailto:el...@googlegroups.com] On Behalf Of
James_2JS
Sent: Friday, August 28, 2009 8:49 AM
To: ELMAH
Subject: [ELMAH] Re: Logging Works Locally But Fails In Production


James_2JS

unread,
Aug 29, 2009, 4:27:45 AM8/29/09
to ELMAH
Hi again,

OK... so you're not logging an errors on the server, but are you able
to see elmah.axd??
If so, go to it and take a look at the bottom line... and the last
sentence.
Does it say XML File-Based Error Log??

Also, go to elmah.axd/test

This should generate a test error... what happens??

Cheers,

James

On Aug 29, 1:47 am, "Zian Choy" <zian.c...@gmail.com> wrote:
> Unfortunately, the server runs Windows Server 2003, which can only run IIS6.
>
> Curioser and curioser...
> Zian Choy
>
>
>
> -----Original Message-----
> From: el...@googlegroups.com [mailto:el...@googlegroups.com] On Behalf Of
>
> James_2JS
> Sent: Friday, August 28, 2009 8:49 AM
> To: ELMAH
> Subject: [ELMAH] Re: Logging Works Locally But Fails In Production
>
> Hi again!
>
> > Actually, it's not in the system.webServer or system.web sections. It's
> > outside of both of them, just like the sample web.config.
>
> Sorry... you're right.. it shouldn't be in <system.web> either...
> DOH!!
>
> What I think you are missing though is adding the httpHandler and the
> httpModule in the <system.webServer> declaration.
> Locally you are running under Cassini or IIS6.
> On the server I guess you are running IIS7.
>
> If I'm right you are missing the following (taken fromhttp://code.google.com/p/elmah/source/browse/trunk/samples/web.config):
> (Obviously you will need to remove the lines that are not applicable
> to your configuration).
>
> <system.webServer>
>          <validation validateIntegratedModeConfiguration="false" />
>          <modules>
>              <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"
> preCondition="managedHandler" />
>              <add name="ErrorFilter" type="Elmah.ErrorFilterModule,
> Elmah" preCondition="managedHandler" />
>              <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"
> preCondition="managedHandler" />
>              <add name="ErrorTweet" type="Elmah.ErrorTweetModule,
> Elmah" preCondition="managedHandler" />
>          </modules>
>          <handlers>
>              <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD"
> type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /
>
>          </handlers>
> </system.webServer>- Hide quoted text -
>
> - Show quoted text -

Atif Aziz

unread,
Aug 30, 2009, 6:01:01 PM8/30/09
to el...@googlegroups.com
I see the friendly error page

Who is showing the friendly error page? I don't see custom errors turned on in your web.config. Could it be that some other component is configured (via machine configuration?) in production to display friendly error pages and may be clearing errors before ELMAH gets to see them?
 
- Atif

Zian Choy

unread,
Sep 1, 2009, 2:05:11 PM9/1/09
to el...@googlegroups.com

Good catch. Sorry, I should have mentioned earlier that I am using ASP .NET MVC, which falls over to Error.aspx for error handling automatically.

 

However, I’ve put in the HandleErrorAttribute.vb class and Elmah still fails to catch the errors. I just tried with the Elmah test exception and it washed ashore in the application event log with nary a peep in the Elmah Error Log.

Sincerely,

Zian Choy

 


From: el...@googlegroups.com [mailto:el...@googlegroups.com] On Behalf Of Atif Aziz
Sent: Sunday, August 30, 2009 3:01 PM
To: el...@googlegroups.com
Subject: [ELMAH] Re: Logging Works Locally But Fails In Production

 

I see the friendly error page

Zian Choy

unread,
Sep 1, 2009, 2:10:17 PM9/1/09
to el...@googlegroups.com
At the bottom, it says "XML File-Based Error Log."

When I go to that page, I get the normal friendly error page that I made
("The problem has been logged...give us a call ...etc.").

Then, when I go back to http://localhost/burrow/elmah.axd, the error log is
empty ("No errors found.").
Sincerely,

James_2JS

unread,
Sep 1, 2009, 2:24:34 PM9/1/09
to ELMAH
Hi again,

I've an idea... what are the security permissions on your ~/App_Data
folder??
(NB For others reading this, this is the folder that has been
configured in the <elmah> config in which to create the Xml files)
I've got a feeling that the OS user that is running your website does
not have create permissions in this folder.

Cheers,

James

On Sep 1, 7:10 pm, "Zian Choy" <zc...@uci.edu> wrote:
> At the bottom, it says "XML File-Based Error Log."
>
> When I go to that page, I get the normal friendly error page that I made
> ("The problem has been logged...give us a call ...etc.").
>
> Then, when I go back tohttp://localhost/burrow/elmah.axd, the error log is
> > - Show quoted text -- Hide quoted text -

Zian Choy

unread,
Sep 2, 2009, 12:14:58 PM9/2/09
to ELMAH
Originall, just read. Now, I tried adding write, and there's no
improvement so it's back to read.

Is there any way to stick breakpoints in to see where the exception is
falling through? Does anyone have experience with doing so?

By the way, is it normal for events that ELMAH catches to still show
up in the event log?
Sincerely,
Zian Choy

James_2JS

unread,
Sep 2, 2009, 12:32:16 PM9/2/09
to ELMAH
OK I think we're getting somewhere here!

> Originall, just read. Now, I tried adding write, and there's no
> improvement so it's back to read.

If the folder only allows you to read, ELMAH will not be able to
create new XML files there.
Can you double check under which account the web application is
running?
(possibly IUSR_*, IWAM_*, ASPNET)

Then check that user's permissions again.

Also, can you check what permissions you have on your development
machine.
Compare and contrast the two and we might have an answer!!
Alternatively, keep removing permission from your dev machine until
ELMAH stops logging!

> Is there any way to stick breakpoints in to see where the exception is
> falling through? Does anyone have experience with doing so?

I haven't looked into this on a remote server

> By the way, is it normal for events that ELMAH catches to still show
> up in the event log?

Yes it is... remember that ELMAH is only intercepting the fact that an
unhandled exception has been raised.
It is not handling the exception, but simply logging it.

Hope this helps!

Cheers,

James

Zian Choy

unread,
Sep 3, 2009, 11:16:57 AM9/3/09
to ELMAH
This needs to go in a FAQ somewhere (if I figure out how to add it to
the wiki, I'll do so).

The basic problem is that Network-service never gets full write
permissions, even if you tick the "Write" box in the properties for
the website in IIS.

Consequently, don't tick the box, it doesn't help. Just right-click on
the folder that you're writing to (e.g. App_Data), click on
"Permissions," click on Network Service, and tick the "Write" box.
Then, click OK.

Thank you all so much for all the help.
Sincerely,
Zian Choy

James_2JS

unread,
Sep 3, 2009, 12:41:32 PM9/3/09
to ELMAH
Excellent!
Glad we got to the bottom of the problem.

Cheers,

James
> > James- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages