星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LogHelper.cs 1.1KB

1 yıl önce
1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839
  1. using log4net.Config;
  2. using System;
  3. using System.IO;
  4. namespace Common.system
  5. {
  6. using XHWK.WKTool.system;
  7. public class LogHelper
  8. {
  9. public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
  10. public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");
  11. public static void InitLog4Net()
  12. {
  13. var logCfg = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
  14. XmlConfigurator.ConfigureAndWatch(logCfg);
  15. loginfo.Info("日志初始化");
  16. }
  17. public static void WriteInfoLog(string info)
  18. {
  19. if (loginfo.IsInfoEnabled)
  20. {
  21. loginfo.Info(info);
  22. Console.WriteLine(info);
  23. }
  24. }
  25. public static void WriteErrLog(string info, Exception ex)
  26. {
  27. if (logerror.IsErrorEnabled)
  28. {
  29. logerror.Error("[V " + FileToolsCommon.GetConfigValue("VersionName") + "]" + info, ex);
  30. }
  31. }
  32. }
  33. }