增加PLC数据的日志记录

This commit is contained in:
liming 蔡
2026-08-14 19:28:16 +08:00
parent a17a969f25
commit 508647ecca
7 changed files with 61 additions and 1 deletions
+15
View File
@@ -18,6 +18,8 @@ namespace JY.Utility
{
private static readonly ILog log;
private static readonly ILog plcLog;
/// <summary>
/// </summary>
public static bool DebugMode = false;
@@ -46,6 +48,8 @@ namespace JY.Utility
Console.WriteLine("Log4net.config 文件未找到,日志将无法正常写入");
}
log = LogManager.GetLogger(repository.Name, "Test");
plcLog = LogManager.GetLogger(repository.Name, "PlcDataLogger");
RunClearJob();
}
@@ -372,6 +376,17 @@ namespace JY.Utility
#endregion
public static void LogPLCData(string name, byte[] data)
{
if (data == null || data.Length == 0)
{
return;
}
string hexString = BitConverter.ToString(data).Replace("-", " ");
plcLog.Info($"{name} : {hexString}");
}
/// <summary>
/// 错误日志带异常