Log4Loggerbak.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. namespace WWPipeLine.Commons
  3. {
  4. internal class Log4Loggerbak : ILogger
  5. {
  6. private static log4net.ILog log = log4net.LogManager.GetLogger("Log");
  7. private static log4net.ILog logError = log4net.LogManager.GetLogger("LogError");
  8. public Log4Loggerbak()
  9. {
  10. log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Paths.ApplicationConfigDir + "/log4net.xml"));
  11. }
  12. public void Trace(string message)
  13. {
  14. Debug(message);
  15. }
  16. public void Debug(string message)
  17. {
  18. try
  19. {
  20. if (log.IsDebugEnabled)
  21. {
  22. log.Debug(message);
  23. }
  24. }
  25. catch
  26. {
  27. }
  28. }
  29. public void Info(string message)
  30. {
  31. try
  32. {
  33. if (log.IsInfoEnabled)
  34. {
  35. log.Info(message);
  36. }
  37. }
  38. catch
  39. {
  40. }
  41. }
  42. public void Warn(string message)
  43. {
  44. try
  45. {
  46. if (log.IsWarnEnabled)
  47. {
  48. log.Warn(message);
  49. }
  50. }
  51. catch
  52. {
  53. }
  54. }
  55. public void Shutdown()
  56. {
  57. log4net.LogManager.Shutdown();
  58. }
  59. public void Error(Exception ex)
  60. {
  61. try
  62. {
  63. if (logError.IsErrorEnabled)
  64. {
  65. logError.Error(ex);
  66. }
  67. }
  68. catch
  69. {
  70. }
  71. }
  72. public void Error(string message)
  73. {
  74. try
  75. {
  76. if (logError.IsErrorEnabled)
  77. {
  78. logError.Error(message);
  79. }
  80. }
  81. catch
  82. {
  83. }
  84. }
  85. public void Fatal(Exception ex)
  86. {
  87. try
  88. {
  89. if (logError.IsFatalEnabled)
  90. {
  91. logError.Fatal(ex);
  92. }
  93. }
  94. catch
  95. {
  96. }
  97. }
  98. public void Fatal(string message)
  99. {
  100. try
  101. {
  102. if (logError.IsFatalEnabled)
  103. {
  104. logError.Fatal(message);
  105. }
  106. }
  107. catch
  108. {
  109. }
  110. }
  111. }
  112. }