c# 实现日志功能
来源:百度知道 编辑:UC知道 时间:2024/06/18 14:22:43
谢谢你,已经明白了好多,基本功能可以实现;但还想问下 ,就是一个项目的事件日志都直接写入系统事件查看器好吗?这样我们都导出或读出日志方便吗?或者我们应该自己定义一个单独的日志文件,存放项目相应的日志?我想问下这两种方式那种更好,更常用? 谢谢你了,会给你加分的,呵呵,
日志?系统日志吧
写入:
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; }