Пример #1
0
 /// <summary>
 /// 写入异常类的上级调用,一般用于公共方法、全局异常捕获等方法里面的异常写入
 /// </summary>
 /// <param name="message"></param>
 /// <param name="exception"></param>
 /// <param name="depth"></param>
 /// <param name="maxDepth"></param>
 public void Error(string message, Exception exception, int depth, int maxDepth = 5)
 {
     try
     {
         log4net.ILog log = log4net.LogManager.GetLogger(new StackTrace(true).GetFrame(depth + 1).GetMethod().DeclaringType);
         log.Error(message + "\r\n" + StackTraceLinkedList.GetStrLinkedList(depth + 2, maxDepth + 2), exception);
     }
     catch (Exception) { }
 }
Пример #2
0
 /// <summary>
 /// 简单日志
 /// </summary>
 /// <param name="message"></param>
 /// <param name="depth"></param>
 /// <param name="maxDepth"></param>
 public void Error(string message, int depth, int maxDepth = 2)
 {
     try
     {
         log4net.ILog log = log4net.LogManager.GetLogger(Paramer(null));
         log.Error(message + "\r\n" + StackTraceLinkedList.GetStrLinkedList(depth + 2, maxDepth + 2));
     }
     catch (Exception) { }
 }