How do I do logging in C# without using 3rd party libraries?

The Solution to How do I do logging in C# without using 3rd party libraries? is


public void Logger(string lines)
{
  //Write the string to a file.append mode is enabled so that the log
  //lines get appended to  test.txt than wiping content and writing the log

  using(System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt", true))
  {
    file.WriteLine(lines);
  }
}

For more information MSDN

~ Answered on 2011-02-20 14:30:30


Most Viewed Questions: