C# Windows Forms & ASP .NET MVC programming
Structured Query Language (SQL)
Smart Marine 3D Ship design
Tribon M3 / AVEVA Marine

Create application log file in C# / Write to File example

2014/10/19 08:55
Application log file example
private string logFile = "full path and file name (C:\\temp\\MyApplicationLog.txt)";
WriteToLogFile("your application message", logFile); // use any time to add record to the log file
public void WriteToLogFile(string strMessage, string outputFile)
   string line = DateTime.Now.ToString() + " | ";
   line += strMessage;
   FileStream fs = new FileStream(outputFile, FileMode.Append, FileAccess.Write, FileShare.None);
   StreamWriter swFromFileStream = new StreamWriter(fs);