我正在尝试将用户在vb.net应用程序中收到的所有错误写到日志文件中,我想知道是否有任何方法可以捕获JIT错误,并且这样做的代码是什么?>
谢谢
答案 0 :(得分:0)
根据nbk在说什么,您可以执行以下操作
Private Sub LogEx()
Try
'Some stuff that will fail
Catch ex As Exception
LogException(Environment.UserName, ex.ToString)
End Try
End Sub
Private Sub LogException(ByVal Username As String, Ex As String)
Dim LogFilePath As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\MyLog.txt"
Dim MyLogFile As IO.StreamWriter =
My.Computer.FileSystem.OpenTextFileWriter(LogFilePath , True)
MyLogFile.WriteLine(Username & "---" & Ex)
MyLogFile.Close()
End Sub