Simple MultiThread Safe Log Class
- by Robert
What is the best approach to creating a simple multithread safe logging class? Is something like this sufficient?
public class Logging
{
public Logging()
{
}
public void WriteToLog(string message)
{
object locker = new object();
lock(locker)
{
StreamWriter SW;
SW=File.AppendText("Data\\Log.txt");
SW.WriteLine(message);
SW.Close();
}
}
}