EventLogEntry.InstanceId プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > EventLogEntry.InstanceId プロパティの意味・解説 

EventLogEntry.InstanceId プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

イベント エントリのメッセージ テキスト指定するリソース識別子取得します

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

<ComVisibleAttribute(False)> _
Public ReadOnly Property
 InstanceId As Long
Dim instance As EventLogEntry
Dim value As Long

value = instance.InstanceId
[ComVisibleAttribute(false)] 
public long InstanceId { get; }
[ComVisibleAttribute(false)] 
public:
property long long InstanceId {
    long long get ();
}
/** @property */
public long get_InstanceId ()

プロパティ
イベント ソースメッセージ リソース ファイル文字列定義に対応するリソース識別子

解説解説

InstanceId プロパティは、構成済みイベント ソースイベント エントリを一意識別します。イベント ログ エントリの InstanceId は、イベント ソースメッセージ リソース ファイル内のイベントについて、32 ビットの完全なリソース識別子表します。EventID プロパティは、上位 2 ビットマスクオフになっている InstanceId等価です。同じソース内の 2 つイベント ログ エントリに、一致する EventID 値を設定できますが、リソース識別子の上位 2 ビット違いにより、InstanceId 値は異なります

アプリケーションが WriteEntry メソッドいずれか使用してイベント エントリを書き込んだ場合InstanceId プロパティオプションeventId パラメータ一致しますアプリケーションが WriteEvent を使用してイベント書き込んだ場合InstanceId プロパティは、instance パラメータの InstanceId で指定されリソース識別子一致しますアプリケーションWin32 API ReportEvent使用してイベント書き込んだ場合InstanceId プロパティは、dwEventID パラメータ指定されリソース識別子一致します

イベント メッセージの定義およびイベント ログ リソース ファイル作成詳細については、http://msdn.microsoft.com のプラットフォーム SDK ドキュメントで「Message Compiler」のトピック参照してくださいイベント ログ識別子詳細については、プラットフォーム SDK の「イベント識別子」のトピック参照してください

使用例使用例

特定のリソース識別子を持つエントリのイベント ログ検索するコード例次に示します。このコード例は、一致する各エントリのイベント メッセージ表示しログ内の一致するエントリの合計数をカウントます。各エントリのメッセージ テキストは、同じ場合もあれば、異な場合あります。各イベント メッセージは、書き込み時に使用されイベント ソース メッセージ ファイル挿入文字列、およびパラメータによって異なります

' Get the event log corresponding to the existing source.
Dim myLogName As String
 = EventLog.LogNameFromSourceName(sourceName,".")
        
' Find each instance of a specific event log entry in a
' particular event log.

Dim myEventLog As EventLog = new
 EventLog(myLogName, ".", sourceName)
Dim count As Integer = 0

Console.WriteLine("Searching event log entries for the event ID
 {0}...", _
   ServerConnectionDownMsgId.ToString())

' Search for the resource ID, display the event text,
' and display the number of matching entries.

Dim entry As EventLogEntry
For Each entry In  myEventLog.Entries
    If entry.InstanceId = ServerConnectionDownMsgId
        count = count + 1
        Console.WriteLine()
        Console.WriteLine("Entry ID    = {0}", _
            entry.InstanceId.ToString())
        Console.WriteLine("Reported at {0}", _
            entry.TimeWritten.ToString())
        Console.WriteLine("Message text:")
        Console.WriteLine(ControlChars.Tab + entry.Message)
    End If
Next entry

Console.WriteLine()
Console.WriteLine("Found {0} events with ID {1} in event log {2}",
 _
    count.ToString(), ServerConnectionDownMsgId.ToString(), myLogName)

// Get the event log corresponding to the existing source.
string myLogName = EventLog.LogNameFromSourceName(sourceName,".");
       
// Find each instance of a specific event log entry in a
// particular event log.

EventLog myEventLog = new EventLog(myLogName, ".");
int count = 0;

Console.WriteLine("Searching event log entries for the event
 ID {0}...",
    ServerConnectionDownMsgId.ToString());

// Search for the resource ID, display the event text,
// and display the number of matching entries.

foreach(EventLogEntry entry in myEventLog.Entries)
{
    if (entry.InstanceId == ServerConnectionDownMsgId)
    {
        count ++;
        Console.WriteLine();
        Console.WriteLine("Entry ID    = {0}", 
            entry.InstanceId.ToString());
        Console.WriteLine("Reported at {0}", 
            entry.TimeWritten.ToString());
        Console.WriteLine("Message text:");
        Console.WriteLine("\t{0}", entry.Message);
    }
}    
Console.WriteLine();
Console.WriteLine("Found {0} events with ID {1} in event
 log {2}.",
    count.ToString(), ServerConnectionDownMsgId.ToString(), myLogName);

// Get the event log corresponding to the existing source.
String^ myLogName = EventLog::LogNameFromSourceName( sourceName, "." );

// Find each instance of a specific event log entry in a
// particular event log.
EventLog^ myEventLog = gcnew EventLog( myLogName,"." );
int count = 0;
Console::WriteLine( "Searching event log entries for the
 event ID {0}...", ServerConnectionDownMsgId );

// Search for the resource ID, display the event text,
// and display the number of matching entries.
System::Collections::IEnumerator^ myEnum = myEventLog->Entries->GetEnumerator();
while ( myEnum->MoveNext() )
{
   EventLogEntry^ entry = safe_cast<EventLogEntry^>(myEnum->Current);
   if ( entry->InstanceId == ServerConnectionDownMsgId )
   {
      count++;
      Console::WriteLine();
      Console::WriteLine( "Entry ID    = {0}", entry->InstanceId );
      Console::WriteLine( "Reported at {0}", entry->TimeWritten );
      Console::WriteLine( "Message text:" );
      Console::WriteLine( "\t{0}", entry->Message );
   }
}

Console::WriteLine();
Console::WriteLine( "Found {0} events with ID {1} in event
 log {2}.", count, ServerConnectionDownMsgId, myLogName );
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventLogEntry クラス
EventLogEntry メンバ
System.Diagnostics 名前空間
EventInstance.InstanceId プロパティ
WriteEvent



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「EventLogEntry.InstanceId プロパティ」の関連用語

EventLogEntry.InstanceId プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



EventLogEntry.InstanceId プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS