Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)delv
published in(发表于) 2014/1/16 9:29:36
c#写系统日志_[Asp.Net教程]

c#写系统日志_[Asp.Net教程]

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace Log
{
class LogWirter
{
///


/// 事件源名称
///

private string eventSourceName;
EventLogEntryType eventLogType;
public LogWirter()
{
eventSourceName = "test";
eventLogType = EventLogEntryType.Error;
}


///


/// 消息事件源名称
///

public string EventSourceName
{
set { eventSourceName = value; }
}


///


/// 消息事件类型
///

public EventLogEntryType EventLogType
{
set { eventLogType = value; }
}


///


/// 写入系统日志
///

/// 事件内容
public void LogEvent(string message)
{
if (!EventLog.SourceExists(eventSourceName))
{
EventLog.CreateEventSource(eventSourceName, "Application");
}
EventLog.WriteEntry(eventSourceName, message, EventLogEntryType.Error);
}
}
}


来源:网络







If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759