📄 systemlog.cs
字号:
using System;
using System.Diagnostics;
namespace MonitorSystem.BasicClass
{
/// <summary>
/// SystemLog 的摘要说明。
/// </summary>
public class SystemLog:EventLog
{
public SystemLog()
{
//Source="MonitorSystem";
}
public void WriteToSysLog(string format)
{
WriteToSysLog(2,format);
}
public void WriteToSysLog(string format, params object[] arg)
{
WriteToSysLog(2,format,arg);
}
/// <summary>
/// 将错误信息写入操作系统日志中
/// </summary>
/// <param name="Msg">要写入的信息</param>
/// <param name="Type">事件类型 0:error,1:information,2:warning</param>
public void WriteToSysLog(int iLevel, string format, params object[] arg)
{
string source="MonitorSystem";
string i_format="";
i_format = String.Format(format, arg);
try
{
switch(iLevel)
{
case 0:
WriteEntry(source,i_format,EventLogEntryType.Error);
break;
case 1:
WriteEntry(source,i_format,EventLogEntryType.Information);
break;
case 2:
WriteEntry(source,i_format,EventLogEntryType.Warning);
break;
default:
WriteEntry(source,i_format,EventLogEntryType.Warning);
break;
}
}
catch
{
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -