At the beginning of your application, your must add a TextWriterTraceListener to the Listeners list of the Debug class.
Module Module1
Sub Main()
Debug.Listeners.Add(New TextWriterTraceListener("Debug of " & DateTime.Now.ToString() & ".txt"))
Debug.WriteLine("Starting aplication")
Console.WriteLine("Press a key to exit")
Console.ReadKey()
Debug.WriteLine("End of application")
End Sub
End Module
All the Debug code produced will be outputed in the Visual Studio console AND in the text file you chose.
If the file is always the same:
Debug.Listeners.Add(New TextWriterTraceListener("Debug.txt"))
The output will be appended to the file every time AND a new file starting with a GUID then your filename will be generated.