How to write to an event log by using Visual C#

using System;
using System.Diagnostics;

namespace WriteToAnEventLog_csharp
{
/// Summary description for Class1.
class Class1
{
static void Main(string[] args)
{
string sSource;
string sLog;
string sEvent;

sSource = "dotNET Sample App";
sLog = "Application";
sEvent = "Sample Event";

if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource,sLog);

EventLog.WriteEntry(sSource,sEvent);
EventLog.WriteEntry(sSource, sEvent,
EventLogEntryType.Warning, 234);
}
}
}
posted @   Javi  阅读(172)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示