如何在不使用第三方库的情况下登录C#?
发布时间:2020-12-16 01:20:49 所属栏目:百科 来源:网络整理
导读:我想在我的应用程序中实现日志记录,但宁愿不使用任何外部框架,如log4net. 所以我想像DOS的echo这样做一个文件.最有效的方法是什么? 有没有办法记录未使用外部框架记录的未处理的异常? 解决方法 public void Logger(String lines){ // Write the string to
我想在我的应用程序中实现日志记录,但宁愿不使用任何外部框架,如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: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |