I would like to implement logging in my application, but would rather not use any outside frameworks like log4net.
So I would like to do something like DOS's echo to a file. What is the most effective way to do it?
Is there a way to log unhandled exceptions logged without using an outside framework?
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