我想在我的应用程序中实现日志记录,但宁愿不使用任何外部框架,如log4net.
所以我想像DOS的echo这样做一个文件.最有效的方法是什么?
有没有办法记录未使用外部框架记录的未处理的异常?
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 System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt",true); file.WriteLine(lines); file.Close(); }
有关更多信息MSDN:
精彩评论