Unable to Log Exceptions With EntLib on production Server

Topics: Exception Handling Application Block
Jan 4, 2007 at 9:53 AM

In my ASP.NET 2 web application I am using Enterprise Library for DataAccess, Exception handling and logging. Everything is working fine on the developers post but as soon as we deploy it on the production server the logging of the exceptions doesnt work.We are using Event Log as well as Email to notify about the exceptions. The server is running under windows 2003 which is the only difference I could see with respect to the developers post (Running under XP). The DataAccess block is working well the problem is only with the logging block of Enterprise Library. There isnt even any exception generated which could specify the reason for not logging the error.

Any suggestion would be of great help.

Thanking in anticipation,

Khurram, Paris
Jan 4, 2007 at 1:29 PM

The major difference between your XP boxes and your W2K3 servers is the security. W2K3 boxes are locked down by default and not all users can write to the Event log.

The support article below tells you how to change the security profile of your users so that they can access the Event Log.


I hope this helps,

Stephen ...
Jan 5, 2007 at 9:12 AM
Ok thanks I would try it out but the thing is that I am using two listeners to log the exceptions the email and the eventlog. If its not working for EventLog it should have been working for the email. Thats why I thought that it could be another problem which at the moment I am unable to figure out.
When we deploy an ASP.NET 2 application by site publication the EntLib dlls are already in the Bin directory of the application. Do we need to do anything else to make it work?

Jan 5, 2007 at 9:23 AM

The EmailTraceListener sends your message via SMTP and I'm not sure if there is a similar security issue with W2K3 lockdown.

It might be worth tracing to a flat file or DB just to rule out a problem with Ent. Lib.

We didn't have to do anything specific to Ent. Lib. itself as far as I can remember.

Stephen ...
Jan 5, 2007 at 12:12 PM
Ye I tried with the flatfile listener but it dint work either. I was logging the exceptions in the OnError event of the page (as I had done the custom base page which was inherited by all other aspx web forms). And I am really surprised to see that when I moved the Error handling code to Global.asax it has started logging in the EventLog as well sending emails.

void Application_Error(object sender, EventArgs e)
// Code qui s'exécute lorsqu'une erreur non gérée se produit
System.Exception exc = Server.GetLastError().GetBaseException();
ExceptionPolicy.HandleException(exc, "Exception Policy");


I have no idea why dint it work with the OnError page event on the production server. By handling it in the Global handler it is working but in the EventLog it is also adding an Advertisement Entry along with the Error stating that an unhadled exception is produced.