| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using log4net;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace LocalhostMES.Core
- {
- public static class LogHelper
- {
- public static readonly ILog loginfo = LogManager.GetLogger("loginfo");
- public static readonly ILog logerror = LogManager.GetLogger("logerror");
- public static readonly ILog logdebug = LogManager.GetLogger("logdebug");
- public static readonly ILog logwarn = LogManager.GetLogger("logwarn");
- public static readonly ILog logfatal = LogManager.GetLogger("logfatal");
- public static readonly ILog logDynamic = LogManager.GetLogger("logDynamic");
- public delegate void LogChangHandler(string msg);
- public static LogChangHandler logChangHandler;
- public static void WriteLogInfo(string info)
- {
- if ( loginfo.IsInfoEnabled )
- {
- loginfo.Info(info);
- logChangHandler?.Invoke(info);
- }
- }
- public static void WriteLogDebug(string info)
- {
- if ( logdebug.IsDebugEnabled )
- {
- logdebug.Debug(info);
- }
- }
- public static void WriteLogWarn(string info)
- {
- if ( logwarn.IsWarnEnabled )
- {
- logwarn.Warn(info);
- }
- }
- public static void WriteLogError(string info, Exception se)
- {
- if ( logerror.IsErrorEnabled )
- {
- logerror.Error(info, se);
- }
- }
- public static void WriteLogFatal(string info, Exception se)
- {
- if ( logfatal.IsFatalEnabled )
- {
- logfatal.Fatal(info, se);
- }
- }
- public static void WriteOther(string info)
- {
- if ( logDynamic.IsInfoEnabled )
- {
- logDynamic.Info(info);
- }
- }
- }
- }
|