// 专门给调度使用,在另外一个进程,只记录 public static void StartDisPatchRecorder(ConfLogServiceInfo confLogServiceInfo) { if (CheckConfig(confLogServiceInfo, out string errMsg)) { DisPatchRecordEnvFlag = true; } else { DisPatchRecordEnvFlag = false; } }
public static void Start(ConfLogServiceInfo confLogServiceInfo, out string errMsg) { errMsg = ""; config = confLogServiceInfo; if (IsRuning) { return; } // 加载日志环境所需的配置文件信息 if (!CheckConfig(config, out errMsg)) { return; } // 打开日志发布者 logPublisher = new LogPublisher(config); logPublisher.Start(out errMsg); if (!logPublisher.IsRuning) { Stop(); return; } // 打开日志记录者 logRecorder = new LogRecorder(fileFullPath, logTableName); logRecorder.Start(); if (!logRecorder.IsRuning) { Stop(); return; } // 打开日志收缩器 logShrink = new LogShrink(fileFullPath, logTableName, config.ManintainTime, config.LogMaxSaveDays); logShrink.Start(); if (!logShrink.IsRuning) { Stop(); return; } // 打开日志管理者 StartMannge(); if (!ManageIsRuning) { Stop(); return; } IsRuning = true; }
private static bool CheckConfig(ConfLogServiceInfo config, out string errMsg) { errMsg = ""; if (!config.EnvIsOkay) { errMsg = config.ErrMsg; return(false); } fileFullPath = config.filePath; logTableName = config.tableName; return(true); }
private void btn_Save_Click(object sender, EventArgs e) { ConfLogServiceInfo info = new ConfLogServiceInfo(); int saveDay = Convert.ToInt32(txt_SaveDay.Text == "" ? "0": txt_SaveDay.Text); int port = Convert.ToInt32(txt_Port.Text == "" ? "0" : txt_Port.Text); if (string.IsNullOrWhiteSpace(dt_wh.Text)) { MessageBox.Show("每天日志维护的时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (saveDay <= 0 && saveDay > 365) { MessageBox.Show("日志保存天数范围不对,1~365!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (port <= 9000 && port >= 65535) { MessageBox.Show("端口范围不对,9000~65535!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } info.ManintainTime = dt_wh.Text; info.LogMaxSaveDays = saveDay; info.Port = port; if (config.UpdateLogInfo(info, out string errMsg)) { MessageBox.Show("更新日志配置信息成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("更新日志配置信息," + errMsg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public LogPublisher(ConfLogServiceInfo confLogServiceInfo) { this.config = confLogServiceInfo; }