增加PLC数据的日志记录
This commit is contained in:
@@ -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>
|
||||
/// 错误日志带异常
|
||||
|
||||
Reference in New Issue
Block a user