NLogHelp.cs 964 B

123456789101112131415161718192021222324252627
  1. using NLog;
  2. using System;
  3. namespace CZKJ.GBRS2.WebMVC.Helper
  4. {
  5. public static class NLogHelp
  6. {
  7. public static Logger logger = LogManager.GetCurrentClassLogger();
  8. public static void ErrorLog(string throwMsg, Exception ex)
  9. {
  10. string errorMsg = string.Format("【异常信息】:{0} <br>【异常类型】:{1} <br>【堆栈调用】:{2}",
  11. new object[] { throwMsg, ex.GetType().Name, ex.StackTrace });
  12. errorMsg = errorMsg.Replace("\r\n", "<br>");
  13. errorMsg = errorMsg.Replace("位置", "<strong style=\"color:red\">位置</strong>");
  14. logger.Error(errorMsg);
  15. }
  16. public static void InfoLog(string operateMsg)
  17. {
  18. string errorMsg = string.Format("【操作信息】:{0} <br>",
  19. new object[] { operateMsg });
  20. errorMsg = errorMsg.Replace("\r\n", "<br>");
  21. logger.Info(errorMsg);
  22. }
  23. }
  24. }