how to save error log in xml file?

D

Dexter

Hello all,

i have a web application ASP.NET with VB.NET.
In the my global.asax file, i want to include a generic code that record all
errors in my application.
I try this:

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim appException As System.Exception = Server.GetLastError()
Dim erros As String = appException.ToString
Dim writer As New XmlTextWriter(Server.MapPath("erro.xml"),
System.Text.Encoding.ASCII)
writer.WriteStartDocument(True)
writer.WriteStartElement("Erro")
writer.WriteElementString("Erro", erros)
writer.WriteEndDocument()
writer.Close()
End Sub

But the execution this code don't finish, it goes only the line three, and
don't save the file.
Somebody know to make this task?

Thanks

Dexter
 

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

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top