using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;namespace Log{  
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace Log
{
class LogWirter
{
/// <summary>
/// 事件源名称
/// </summary>
private string eventSourceName;
EventLogEntryType eventLogType;
public LogWirter()
{
eventSourceName = "test";
eventLogType = EventLogEntryType.Error;
}
/// <summary>
/// 消息事件源名称
/// </summary>
public string EventSourceName
{
set { eventSourceName = value; }
}
/// <summary>
/// 消息事件类型
/// </summary>
public EventLogEntryType EventLogType
{
set { eventLogType = value; }
}
/// <summary>
/// 写入系统日志
/// </summary>
/// <param name="message">事件内容</param>
public void LogEvent(string message)
{
if (!EventLog.SourceExists(eventSourceName))
{
EventLog.CreateEventSource(eventSourceName, "Application");
}
EventLog.WriteEntry(eventSourceName, message, EventLogEntryType.Error);
}
}
}
声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!