C#输出日志记录
2016-11-07 17:49
274 查看
string vsPath = @"C:\InterFace\";
if (!System.IO.Directory.Exists(vsPath))
System.IO.Directory.CreateDirectory(vsPath);
try
{
DateTime currentTime = System.DateTime.Now;
vsPath = vsPath + "GS_InterFace_CodeOutPutLog" + currentTime.ToString("yyyyMMdd") + ".txt";
System.IO.StreamWriter sw = new System.IO.StreamWriter(vsPath, true, System.Text.Encoding.Default);
sw.WriteLine("记录时间:{0}", DateTime.Now.ToString());
sw.WriteLine("信息文本:{0}", logMessage);
sw.WriteLine("---------------------------------------------------------------------------------------------");
sw.Flush();
sw.Close();
}
catch (Exception ex)
{
}
if (!System.IO.Directory.Exists(vsPath))
System.IO.Directory.CreateDirectory(vsPath);
try
{
DateTime currentTime = System.DateTime.Now;
vsPath = vsPath + "GS_InterFace_CodeOutPutLog" + currentTime.ToString("yyyyMMdd") + ".txt";
System.IO.StreamWriter sw = new System.IO.StreamWriter(vsPath, true, System.Text.Encoding.Default);
sw.WriteLine("记录时间:{0}", DateTime.Now.ToString());
sw.WriteLine("信息文本:{0}", logMessage);
sw.WriteLine("---------------------------------------------------------------------------------------------");
sw.Flush();
sw.Close();
}
catch (Exception ex)
{
}
相关文章推荐
- 在 C# 控制台中记录异常日志并输出
- C#中实现日志记录输出
- SQL Server BI Step by Step SSIS 7 (End) --- 事务,错误输出,事件处理,日志记录
- SQL Server BI Step by Step SSIS 7 (End) --- 事务,错误输出,事件处理,日志记录
- java日志记录,并将该记录输出到自定义的窗口中(一)
- C# 简易日志记录类
- C# 自动查找文件内容(正则使用、获取目录下所有文件、多线程、日志记录,文件操作)
- 基于事件日志的访问记录(c#)以后备用!
- C#中使用Log4Net记录日志
- c# .net 如何使用log4net记录日志
- 程序日志中自动记录所在函数名、文件名、行号,并定向输出到一个日志文件
- C#方法 记录程序日志的方法
- c# 使用后台线程进行日志记录
- 错误记录(spring定时重复执行 log4j日志重复输出)
- 用C#记录网站日志
- C# Winform 运用Log4Net记录日志
- SQL Server BI Step by Step SSIS 7 (End) --- 事务,错误输出,事件处理,日志记录
- 20101007 学习记录:c#数字化格式输出
- C#创建创建文本文件写入读取,可以用来做系统日志或程序操作日志或者错误记录
- C# 输出 PDF 资料记录