I use public variable and timer appending new lines to txt file.
E.g.
Public Class Form1
Public WriteToLog = ""
Dim LogFilePath As String = My.Application.Info.DirectoryPath & "\applog.txt"
....
Public Function Log_to_txt(ByVal text As String)
Dim CurDate As String
CurDate = Format(Now, "General Date")
WriteToLog = WriteToLog & "[" & CurDate & "] " & text & vbCrLf
Return True
End Function
...
Log_to_txt("Application started...")
...
Private Sub WriteToLogTimer_Tick(sender As Object, e As EventArgs) Handles WriteToLogTimer.Tick
Dim CatchLog As String = WriteToLog
WriteToLog = ""
Try
My.Computer.FileSystem.WriteAllText(LogFilePath, CatchLog, True)
Catch ex As IOException
End Try
End Sub