我希望在我的应用程序中实现日志(log)记录,但不愿使用任何外部框架,如log4net.
所以我想对一个文件执行类似于DOS echo的操作.做这件事最有效的方法是什么?
有没有一种方法可以在不使用外部框架的情况下记录未处理的异常?
我希望在我的应用程序中实现日志(log)记录,但不愿使用任何外部框架,如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
using(System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt", true))
{
file.WriteLine(lines);
}
}
欲了解更多信息,请点击MSDN