Log4NetHelper.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml;
  7. namespace PacsView3D
  8. {
  9. public class Log4NetHelper
  10. {
  11. private static Dictionary<string, log4net.ILog> m_lstLog = new Dictionary<string, log4net.ILog>();
  12. public static void InitLog4Net(string strLog4NetConfigFile)
  13. {
  14. log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(strLog4NetConfigFile));
  15. }
  16. public static readonly log4net.ILog logInfo = log4net.LogManager.GetLogger("loginfo");
  17. public static readonly log4net.ILog logError = log4net.LogManager.GetLogger("logerror");
  18. public static readonly log4net.ILog logDebug = log4net.LogManager.GetLogger("logdebug");
  19. public static void WriteLog(string info)
  20. {
  21. if (logInfo.IsInfoEnabled)
  22. {
  23. logInfo.Info(info);
  24. }
  25. }
  26. public static void WriteLog(string info, Exception ex)
  27. {
  28. if (logError.IsErrorEnabled)
  29. {
  30. logError.Error(info, ex);
  31. }
  32. }
  33. public static void WriteLogDebug(string info, Exception ex)
  34. {
  35. if (logDebug.IsDebugEnabled)
  36. {
  37. logDebug.Debug(info, ex);
  38. }
  39. }
  40. }
  41. }