Basic Datewise Log feature in .NET

Here is the simple log method which logs in file. It will creates log file per day.

Public Shared Sub Log(ByVal strLogMessage As String)
Try
Dim strWr As StreamWriter = File.AppendText(Environment.CurrentDirectory & "\Logs\" & Date.Now.ToString("MM-dd-yyyy") & ".log")
strWr.WriteLine(DateTime.Now.ToString & " " & strLogMessage)
strWr.Close()
Catch ex As Exception
End Try
End Sub

No comments:

Post a Comment