Created
May 23, 2012 03:06
-
-
Save ichiroku11/2773041 to your computer and use it in GitHub Desktop.
System.Diagnostics.EventLogのサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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