LogHelper.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using log4net;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace TeamAAS_VP
  8. {
  9. public static class LogHelper
  10. {
  11. public static readonly ILog loginfo = LogManager.GetLogger("loginfo");
  12. public static readonly ILog logerror = LogManager.GetLogger("logerror");
  13. public static readonly ILog logdebug = LogManager.GetLogger("logdebug");
  14. public static readonly ILog logwarn = LogManager.GetLogger("logwarn");
  15. public static readonly ILog logfatal = LogManager.GetLogger("logfatal");
  16. public static readonly ILog logDynamic = LogManager.GetLogger("logDynamic");
  17. public static void WriteLogInfo(string info)
  18. {
  19. if (loginfo.IsInfoEnabled)
  20. {
  21. loginfo.Info(info);
  22. }
  23. }
  24. public static void WriteLogDebug(string info)
  25. {
  26. if (logdebug.IsDebugEnabled)
  27. {
  28. logdebug.Debug(info);
  29. }
  30. }
  31. public static void WriteLogWarn(string info)
  32. {
  33. if (logwarn.IsWarnEnabled)
  34. {
  35. logwarn.Warn(info);
  36. }
  37. }
  38. public static void WriteLogError(string info, Exception se)
  39. {
  40. if (logerror.IsErrorEnabled)
  41. {
  42. logerror.Error(info, se);
  43. }
  44. }
  45. public static void WriteLogFatal(string info, Exception se)
  46. {
  47. if (logfatal.IsFatalEnabled)
  48. {
  49. logfatal.Fatal(info, se);
  50. }
  51. }
  52. public static void WriteOther(string info)
  53. {
  54. if (logDynamic.IsInfoEnabled)
  55. {
  56. logDynamic.Info(info);
  57. }
  58. }
  59. }
  60. }