c#写系统日志

时间:2008-11-27 11:35:10   来源:第二电脑网上收集  作者:

  第二电脑网导读:p;      /// <summary>        /// 事件源名称        /// </summary>        private string eventSourceName;        EventLogEntryType eventLogType; &nbs...
  正文: 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);
        }
    }
}


来源:http://www.002pc.com/master/College/Language/C/2008-11-27/4636.html

收藏到:

关于《c#写系统日志》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='95' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='95' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td