By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,920 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,920 IT Pros & Developers. It's quick & easy.

how to save error log in xml file?

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You might want to wrap that in an try/catch block and see what the exception
might be.
BTW: You might want to look into Exception Management Application block
(http://msdn.microsoft.com/library/de...-us/dnbda/html
/emab-rm.asp) which might be a better way to deal with errors/exceptions.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"Dexter" <pr******@yahoo.com.br> wrote in message
news:uE**************@tk2msftngp13.phx.gbl...
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.