?? 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 + -