C# Logger - Write strings to log file


public class Logger
{
public static bool _doLog = true;

public static void Log(String filename, String Message)
{
if (!_doLog)
return;

if (File.Exists(filename))
{
using (StreamWriter sw = File.AppendText(filename))
{
sw.WriteLine(String.Format("{0} : {1}", DateTime.Now, Message));
sw.Close();
}
}
else
{
using (StreamWriter sw = File.CreateText(filename))
{
sw.WriteLine(String.Format("{0} : {1}", DateTime.Now, Message));
sw.Close();
}
}
}
}