Writing error to Application Log in ASP.Net 2.0

D

David Lozzi

Howdy,

I'm working on some error handling for my application. Currently on WinXP
Pro SP2. Basically this is what I'm doing:

Try...Catch at the method level, Catch sends email with error

Page_error has code:
Throw Server.GetLastError

Application_error in global.asax has code:

Dim LogSource As String = ConfigurationManager.AppSettings("WebsiteName")

Dim LastExc As Exception = Server.GetLastError

Dim message As String = LastExc.Message & "<br>" & LastExc.ToString

EventLog.WriteEntry(LogSource, message, EventLogEntryType.Error)


web.config has
<customErrors mode="On" defaultRedirect="~/error.aspx"/>


When an error occurs the browser sends to error.aspx fine, but nothing is
written to the Application log. Here's what I get there
The following exception was thrown by the web event provider
'EventLogProvider' in the application '/patterns' (in an application
lifetime a maximum of one exception will be logged per provider instance):

System.Web.HttpException: The EventLogWebEventProvider provider failed to
log an event with the error code 0x800705DE.

at System.Web.Management.EventLogWebEventProvider.ProcessEvent(WebBaseEvent
eventRaised)

at System.Web.Management.WebBaseEvent.RaiseInternal(WebBaseEvent
eventRaised, ArrayList firingRuleInfos, Int32 index0, Int32 index1)

For more information, see Help and Support Center at

I've added the LogSource as specified in the code above to
HKLM\System\CurrentControlSet\Services\Eventlog\Application as a Key. From
what I've read, I should do a Server.Transfer in the Application_Error
function, not use the customError defaultRedirect in web.config. If I set it
up like this, nothing happens, I get the generic.net error page.

So to sum up, I'm trying to get error handling at the application level
working so that the Application Log will receive the error and I would like
the error to be sent to the error.aspx page if possible to display in the
event they call customer service. I will be notified of the error first when
the Catch sends the email.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top