LogHelper.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using NLog;
  6. namespace Bowin.Common.Log
  7. {
  8. public enum LogType
  9. {
  10. CommmLog, //通用日志
  11. ServiceLog
  12. }
  13. public class LogHelper
  14. {
  15. /// <summary>
  16. /// 直接使用这个的话,类型就是Info(信息)
  17. /// </summary>
  18. /// <param name="logType"></param>
  19. /// <param name="message"></param>
  20. public static void WriteLog(LogType logType, string message)
  21. {
  22. //不要重载
  23. LogManager.GetLogger(logType.ToString()).Log(LogLevel.Info, message.Replace("'", "''"));
  24. }
  25. public static void WriteErrorLog(LogType logType, string message)
  26. {
  27. //不要重载
  28. LogManager.GetLogger(logType.ToString()).Log(LogLevel.Error, message.Replace("'", "''"));
  29. }
  30. public static void WriteLog(LogType logType, string message, LogLevel logLevel)
  31. {
  32. //不要重载
  33. LogManager.GetLogger(logType.ToString()).Log(logLevel, message.Replace("'", "''"));
  34. }
  35. public static void WriteDebugLog(LogType logType, string message)
  36. {
  37. //不要重载
  38. LogManager.GetLogger(logType.ToString()).Log(LogLevel.Debug, message.Replace("'", "''"));
  39. }
  40. }
  41. }