All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

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

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/16 9:29:36 Browse times: 413 Comment times: 0

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


Head photo

Go homepage
Upload pictures
Write articles

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);
}
}
}




来源:网络






































There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.