12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- namespace CommonUtils.Log4
- {
- public class LogHelper
- {
- public delegate void ServerLogChangHandler(Log log);
- public delegate void PrinterLogChangHandler(Log log);
- public delegate void AgvLogChangHandler(Log log);
- // #region 执行日志
- private static readonly log4net.ILog infologger = log4net.LogManager.GetLogger("LogInfo");
- /// <summary>
- /// 普通日志
- /// </summary>
- /// <param name="message">日志内容</param>
- public static void Info(string message)
- {
- // 可以改成type typeof(类)
- if ( infologger.IsInfoEnabled)
- {
- infologger.Info(message);
- }
- }
- private static log4net.ILog alarmlog4net =log4net.LogManager.GetLogger("AlarmLogInfo");
- /// <summary>
- /// 警告日志
- /// </summary>
- /// <param name="message">警告日志</param>
- public static void Warn(string message)
- {
-
- if ( alarmlog4net.IsWarnEnabled )
- {
- alarmlog4net.Warn(message);
- }
-
- }
- private static log4net.ILog Errlog4net =log4net.LogManager.GetLogger("ErrLogInfo");
- /// <summary>
- /// 错误日志
- /// </summary>
- /// <param name="message">错误日志</param>
- public static void Error(string message)
- {
-
- if ( Errlog4net.IsInfoEnabled )
- {
- Errlog4net.Error(message);
- }
-
- }
- }
- public class Log
- {
- private string time;
- private string msg;
-
- public string Time { get => time; set => time = value; }
- public string Msg { get {return time +" "+ msg; } set => msg = value; }
- }
-
- }
|