1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Public Overloads Shared Sub LogException(ByVal RaisedException As System.Exception, ByVal ApplicationMessage As String, ByVal ID as String)
Dim AppLogFile As String = My.Application.Info.DirectoryPath.Substring(0, 3)
AppLogFile &= My.Application.Info.ProductName
AppLogFile &= IO.Path.DirectorySeparatorChar
If Not My.Computer.FileSystem.DirectoryExists(AppLogFile) Then
My.Computer.FileSystem.CreateDirectory(AppLogFile)
End If
AppLogFile &= ID & "_LogException.txt"
Using swLogWriter As StreamWriter = File.AppendText(AppLogFile)
swLogWriter.WriteLine("-------------------------------Start Log Entry-------------------------------")
If Not IsNothing(RaisedException) Then
LogExceptionOnFile(RaisedException, ApplicationMessage, swLogWriter, False)
Else
LogExceptionOnFile(New System.Exception("No Exception To Log"), ApplicationMessage, swLogWriter, False)
End If
swLogWriter.WriteLine("-------------------------------End Log Entry---------------------------------")
swLogWriter.Close()
End Using
End Sub |