2026-07-14 13:55:17 +08:00
|
|
|
using log4net;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace JY.Inspection
|
|
|
|
|
{
|
|
|
|
|
internal class Log4Helper
|
|
|
|
|
{
|
2026-08-14 19:28:16 +08:00
|
|
|
// 通过名称获取专属的 PLC Logger
|
|
|
|
|
private static readonly ILog plcLog = LogManager.GetLogger("PlcDataLogger");
|
|
|
|
|
|
2026-07-14 13:55:17 +08:00
|
|
|
public static void WriteLog(Type t, Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ILog log = LogManager.GetLogger(t);
|
|
|
|
|
log.Error(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void WriteLog(Type t, string msg)
|
|
|
|
|
{
|
|
|
|
|
ILog log = LogManager.GetLogger(t);
|
|
|
|
|
log.Info(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void WriteLog(string className, Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ILog log = LogManager.GetLogger(className);
|
|
|
|
|
log.Error(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void WriteLog(string className, string msg)
|
|
|
|
|
{
|
|
|
|
|
ILog log = LogManager.GetLogger(className);
|
|
|
|
|
log.Info(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|