C#对windows系统日志操作(对日志的查看删除 和保护(恢复与备份)) .net2.0框架下

evjen 2009-04-16 10:34:00
谢谢各位大侠,最好有参考代码...
分数不够可以再加...
...全文
647 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
冷月孤峰 2009-04-17
  • 打赏
  • 举报
回复
英雄在线 2009-04-17
  • 打赏
  • 举报
回复
友情帮顶
zhanluozhen 2009-04-17
  • 打赏
  • 举报
回复
用Evenlog
suners 2009-04-17
  • 打赏
  • 举报
回复
友情UP 谁懂了也可以学学了 学而不厌
悔说话的哑巴 2009-04-17
  • 打赏
  • 举报
回复
using System;
using System.Diagnostics;
using System.Threading;

class Test{

public static void Main(){

if(!EventLog.SourceExists("MySource")){
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatingEventSource");
}

EventLog myLog = new EventLog();
myLog.Source = "MySource";

myLog.WriteEntry("一条新日志.");
}
}


借鉴一下
itcrazyman 2009-04-17
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 hangang7403 的回复:]
用eventlog
[/Quote]
mark up 帮顶
hangang7403 2009-04-17
  • 打赏
  • 举报
回复
用eventlog
boywangliang 2009-04-17
  • 打赏
  • 举报
回复
学习
from911cs 2009-04-17
  • 打赏
  • 举报
回复
up
freewind0521 2009-04-17
  • 打赏
  • 举报
回复
写入系统日志

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);
}
}
}
TkingCN 2009-04-17
  • 打赏
  • 举报
回复
顶一下 接个分
a123553628 2009-04-16
  • 打赏
  • 举报
回复
提供一个参考 http://www.qostudy.org/pr/Article/aspnet/c/200605/17345.html
coodd 2009-04-16
  • 打赏
  • 举报
回复

using System;
using System.Diagnostics;
using System.Threading;

class Test{

public static void Main(){

if(!EventLog.SourceExists("MySource")){
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatingEventSource");
}

EventLog myLog = new EventLog();
myLog.Source = "MySource";

myLog.WriteEntry("一条新日志.");
}
}

createWang 2009-04-16
  • 打赏
  • 举报
回复
Microsoft.Win32.Registry 类

Microsoft.Win32.RegistryKey 类
看看MSDN

或许这篇文章可以帮助你
http://blog.csdn.net/venus0314/services/trackbacks/408893.aspx
evjen 2009-04-16
  • 打赏
  • 举报
回复
windows窗体程序
蓝海D鱼 2009-04-16
  • 打赏
  • 举报
回复
在 System.Diagnostics 下 有一个 eventlog 对象 所有系统日志操作都是 这个 看看MSDN 应该很容易的
不过 如果 是 WEB程序 需要写入系统 日志的话 需要 一些特定配置
Dim eventlog As New eventlog
'writing to log
eventlog.WriteEntry(strErr, EventLogEntryType.Error)
yagebu1983 2009-04-16
  • 打赏
  • 举报
回复
应该是调用API函数。。。

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧