Skip to content

Instantly share code, notes, and snippets.

@ichiroku11
Created May 23, 2012 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichiroku11/2773041 to your computer and use it in GitHub Desktop.
Save ichiroku11/2773041 to your computer and use it in GitHub Desktop.
System.Diagnostics.EventLogのサンプル
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApp {
static class Program {
static void Main( string[] args ) {
var source = "ConsoleApp"; // イベントソース名
// イベントソースが登録されていなければ作成
if( !EventLog.SourceExists( source ) ) {
EventLog.CreateEventSource( source, "Application" );
}
// イベントログにエントリを書き込み
EventLog.WriteEntry( source, "Information entry.", EventLogEntryType.Information );
EventLog.WriteEntry( source, "Warning entry.", EventLogEntryType.Warning );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment