1.C# 方法

/// <summary>
/// 异常处理
/// </summary>
/// <returns></returns>
public void GetLogInfo()
{
string msg = string.Empty; try
{
string str="这是程序代码";
}
catch (Exception ex)
{
msg = ex.Message;
isSavedSuccessfully = false;
WoExcepitonLog wl = new WoExcepitonLog();
wl.WriteLog(ex, "WO_Exception.txt");
wl.CreateLog(ex, (this.SessionExt().Get<SessionUser>() as SessionUser).UserId, WOExceptionType.SaveException, "");
throw new TeldWOException(WOExceptionType.SaveException, ex);
}
}

2.输出日志方法

public class ExcepitonLog
{
private static object m_Lock = new object();
string dic = @"C:\Logs";
string RealTimeData = "WO_RealTimeData.txt";//运行数据
string RealTimeException = "WO_Exception.txt";//异常
public void WriteLog(Exception ce, string fileName)
{
if (!Directory.Exists(dic))//判断是否存在
{
Directory.CreateDirectory(dic);//创建新路径
}
lock (m_Lock)
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(dic + "\\" + fileName, true))
{
file.WriteLine("------------------------------" + DateTime.Now.ToString() + "------------------------------");
file.WriteLine(ce.StackTrace);
file.WriteLine(ce.Source);
file.WriteLine(ce.TargetSite);
file.WriteLine(ce.Message);
}
}
}
}

  后续完善

最新文章

  1. 微信开发中遇到“当前页面的url未注册”问题
  2. JAVASCRIPT中经典面试题
  3. 使用了Windows Live Writer 写的博客
  4. 调试时屏蔽JavaScript库代码 –Chrome DevTools Blackbox功能介绍
  5. 【多线程】Java并发编程:Lock(转载)
  6. 关于iOS中SQLITE句柄的使用的细节
  7. Joseph cicyle&#39;s algorithm
  8. Nyoj 43 24 Point game 【DFS】
  9. yii操作数据库(AR)
  10. Struts2 一张图片引发的bug
  11. 实现strcmp非常easy的思维
  12. codeforces 466d Increase Sequence
  13. 阿里ECS配置MSSQL远程连接的坑
  14. Linux批量结束、杀死进程
  15. 详细集成Redis (一)
  16. C# log4net 使用
  17. BZOJ4541 HNOI2016矿区(平面图转对偶图)
  18. C# 各种控件实现可拖动和调整大小
  19. shell编程小结
  20. cmd.exe启动参数详解

热门文章

  1. 阅读笔记06-架构师必备最全SQL优化方案(2)
  2. TP 验证码
  3. 如何创建 Qt 插件?
  4. C# json格式的序列化与反序列化
  5. Identity MVC:UI
  6. JSONP面试
  7. resolver - 解析器(resolver) 配置文件
  8. 06.Linux-RedHat系统网卡服务连不上活跃连接路径变化
  9. axis2获取request方法
  10. vue内置组件——transition简单原理图文详解