EventLogEntryとは? わかりやすく解説

EventLogEntry イベント


EventLogEntry クラス

イベント ログの単一レコードをカプセル化します。このクラスは継承できません。

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

<SerializableAttribute> _
Public NotInheritable Class
 EventLogEntry
    Inherits Component
    Implements ISerializable
Dim instance As EventLogEntry
[SerializableAttribute] 
public sealed class EventLogEntry : Component,
 ISerializable
[SerializableAttribute] 
public ref class EventLogEntry sealed : public
 Component, ISerializable
/** @attribute SerializableAttribute() */ 
public final class EventLogEntry extends Component
 implements ISerializable
SerializableAttribute 
public final class EventLogEntry extends
 Component implements ISerializable
解説解説

EventLog クラスを使用する場合は、通常 EventLogEntry のインスタンスを直接作成することはありません。EventLog クラスの Entries のメンバは、EventLogEntry インスタンスのコレクションを格納しています。EventLogEntryCollection.Item クラスのインデックス メンバを使用して読み取る場合、これは反復処理されます。

Windows 98, Windows Millennium Edition プラットフォームメモ : イベント ログは、Windows 98 または Windows Millennium Edition ではサポートされていません。

使用例使用例
Imports System
Imports System.Diagnostics

Class MyEventlogClass

   Public Shared Sub Main()
      Dim myEventType As String
 = Nothing
      ' Associate the instance of 'EventLog' with local System Log.
      Dim myEventLog As New
 EventLog("System", ".")
      Console.WriteLine("1:Error")
      Console.WriteLine("2:Information")
      Console.WriteLine("3:Warning")
      Console.WriteLine("Select the Event Type")
      Dim myOption As Integer
 = Convert.ToInt32(Console.ReadLine())
      Select Case myOption
         Case 1
            myEventType = "Error"
         Case 2
            myEventType = "Information"
         Case 3
            myEventType = "Warning"
         Case Else
      End Select

      Dim myLogEntryCollection As EventLogEntryCollection
 = myEventLog.Entries
      Dim myCount As Integer
 = myLogEntryCollection.Count
      ' Iterate through all 'EventLogEntry' instances in 'EventLog'.
      Dim i As Integer
      For i = myCount - 1 To -1 Step
 -1
         Dim myLogEntry As EventLogEntry =
 myLogEntryCollection(i)
         ' Select the entry having desired EventType.
         If myLogEntry.EntryType.ToString().Equals(myEventType)
 Then
            ' Display Source of the event.
            Console.WriteLine(myLogEntry.Source + " was the source
 of last "& _
                             "event of type " &
 myLogEntry.EntryType.ToString())
            Return
         End If
      Next i

   End Sub 'Main
End Class 'MyEventlogClass
using System;
using System.Diagnostics;
   class MyEventlogClass
   {
      public static void
 Main()
      {
         String myEventType=null;
         // Associate the instance of 'EventLog' with local System Log.
         EventLog myEventLog = new EventLog("System",
 ".");
         Console.WriteLine("1:Error");
         Console.WriteLine("2:Information");
         Console.WriteLine("3:Warning");
         Console.WriteLine("Select the Event Type");
         int myOption=Convert.ToInt32(Console.ReadLine());
         switch(myOption)
         {
            case 1:  myEventType="Error";
                     break;
            case 2:  myEventType="Information";
                     break;
            case 3:  myEventType="Warning";
                     break;
            default: break;
         }

            EventLogEntryCollection myLogEntryCollection=myEventLog.Entries;
            int myCount =myLogEntryCollection.Count;
            // Iterate through all 'EventLogEntry' instances in 'EventLog'.
            for(int i=myCount-1;i>0;i--)
            {
               EventLogEntry myLogEntry = myLogEntryCollection[i];
               // Select the entry having desired EventType.
               if(myLogEntry.EntryType.ToString().Equals(myEventType))
               {
                  // Display Source of the event.
                  Console.WriteLine(myLogEntry.Source
                     +" was the source of last event of type "
                     +myLogEntry.EntryType);
                  return;
               }
            }

         }
   }
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

int main()
{
   String^ myEventType = nullptr;
   
   // Associate the instance of 'EventLog' with local System Log.
   EventLog^ myEventLog = gcnew EventLog( "System","." );
   Console::WriteLine( "1:Error" );
   Console::WriteLine( "2:Information" );
   Console::WriteLine( "3:Warning" );
   Console::WriteLine( "Select the Event Type" );
   int myOption = Convert::ToInt32( Console::ReadLine() );
   switch ( myOption )
   {
      case 1:
         myEventType = "Error";
         break;

      case 2:
         myEventType = "Information";
         break;

      case 3:
         myEventType = "Warning";
         break;

      default:
         break;
   }
   EventLogEntryCollection^ myLogEntryCollection = myEventLog->Entries;
   int myCount = myLogEntryCollection->Count;
   
   // Iterate through all 'EventLogEntry' instances in 'EventLog'.
   for ( int i = myCount - 1; i > 0; i--
 )
   {
      EventLogEntry^ myLogEntry = myLogEntryCollection[ i ];
      
      // Select the entry having desired EventType.
      if ( myLogEntry->EntryType.Equals( myEventType ) )
      {
         // Display Source of the event.
         Console::WriteLine( "{0} was the source of last event of type {1}",
 myLogEntry->Source, myLogEntry->EntryType );
         return 0;
      }
   }
}
import System.*;
import System.Diagnostics.*;

class MyEventlogClass
{
    public static void main(String[]
 args)
    {
        String myEventType = null;

        // Associate the instance of 'EventLog' with local System Log.
        EventLog myEventLog = new EventLog("System",
 ".");
        Console.WriteLine("1:Error");
        Console.WriteLine("2:Information");
        Console.WriteLine("3:Warning");
        Console.WriteLine("Select the Event Type");
        int myOption = Convert.ToInt32(Console.ReadLine());
        switch (myOption) {
            case 1:
                myEventType = "Error";
                break;

            case 2:
                myEventType = "Information";
                break;

            case 3:
                myEventType = "Warning";
                break;

            default:
                break;
        }

        EventLogEntryCollection myLogEntryCollection = myEventLog.get_Entries();
        int myCount = myLogEntryCollection.get_Count();

        // Iterate through all 'EventLogEntry' instances in 'EventLog'.
        for (int i = myCount - 1; i > 0;
 i--) {
            EventLogEntry myLogEntry = myLogEntryCollection.get_Item(i);

            // Select the entry having desired EventType.
            if (myLogEntry.get_EntryType().ToString().Equals(myEventType))
 {
                // Display Source of the event.
                Console.WriteLine(myLogEntry.get_Source() 
                    + " was the source of last event of type " 
                    + myLogEntry.get_EntryType());
                return;
            }
        }
    } //main
} //MyEventlogClass 
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
      System.Diagnostics.EventLogEntry
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventLogEntry メンバ
System.Diagnostics 名前空間
EventLog クラス
EventLogEntryCollection
EventInstance クラス

EventLogEntry プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Category このエントリの CategoryNumber プロパティに関連付けられているテキストを取得します。
パブリック プロパティ CategoryNumber イベント ログ エントリのカテゴリ番号を取得します。
パブリック プロパティ Container  Component を格納している IContainer を取得します。 ( Component から継承されます。)
パブリック プロパティ Data エントリに関連付けられているバイナリ データを取得します。
パブリック プロパティ EntryType エントリのイベントの種類を取得します。
パブリック プロパティ EventID 現在のイベント エントリのアプリケーション固有のイベント識別子を取得します。
パブリック プロパティ Index イベント ログでのエントリのインデックスを取得します。
パブリック プロパティ InstanceId イベント エントリのメッセージ テキストを指定するリソース識別子を取得します。
パブリック プロパティ MachineName エントリを生成したコンピュータの名前を取得します。
パブリック プロパティ Message イベント エントリに関連付けられているローカライズ済みのメッセージを取得します。
パブリック プロパティ ReplacementStrings エントリに関連付けられている置換文字列を取得します。
パブリック プロパティ Site  Component の ISite を取得または設定します。 ( Component から継承されます。)
パブリック プロパティ Source イベントを発生させたアプリケーションの名前を取得します。
パブリック プロパティ TimeGenerated イベントが生成された現地時間を取得します。
パブリック プロパティ TimeWritten イベントがログに書き込まれた現地時間を取得します。
パブリック プロパティ UserName イベントを発生させたユーザーの名前を取得します。
参照参照

関連項目

EventLogEntry クラス
System.Diagnostics 名前空間
EventLog クラス
EventLogEntryCollection
EventInstance クラス

EventLogEntry メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Dispose  Component によって使用されているすべてのリソースを解放します。 ( Component から継承されます。)
パブリック メソッド Equals オーバーロードされます。 2 つの項目を比較します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  Component の名前を格納している String を返します (存在する場合)。このメソッドはオーバーライドできません。 ( Component から継承されます。)
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Runtime.Serialization.ISerializable.GetObjectData SerializationInfo に、オブジェクトをシリアル化するために必要なデータを設定します。
参照参照

関連項目

EventLogEntry クラス
System.Diagnostics 名前空間
EventLog クラス
EventLogEntryCollection
EventInstance クラス

EventLogEntry メンバ

イベント ログの単一レコードをカプセル化します。このクラスは継承できません。

EventLogEntry データ型で公開されるメンバを以下の表に示します。


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Category このエントリの CategoryNumber プロパティに関連付けられているテキストを取得します。
パブリック プロパティ CategoryNumber イベント ログ エントリのカテゴリ番号を取得します。
パブリック プロパティ Container  Component を格納している IContainer を取得します。(Component から継承されます。)
パブリック プロパティ Data エントリに関連付けられているバイナリ データを取得します。
パブリック プロパティ EntryType エントリのイベントの種類を取得します。
パブリック プロパティ EventID 現在のイベント エントリのアプリケーション固有のイベント識別子を取得します。
パブリック プロパティ Index イベント ログでのエントリのインデックスを取得します。
パブリック プロパティ InstanceId イベント エントリのメッセージ テキストを指定するリソース識別子を取得します。
パブリック プロパティ MachineName エントリを生成したコンピュータの名前を取得します。
パブリック プロパティ Message イベント エントリに関連付けられているローカライズ済みのメッセージを取得します。
パブリック プロパティ ReplacementStrings エントリに関連付けられている置換文字列を取得します。
パブリック プロパティ Site  Component の ISite を取得または設定します。(Component から継承されます。)
パブリック プロパティ Source イベントを発生させたアプリケーションの名前を取得します。
パブリック プロパティ TimeGenerated イベントが生成された現地時間を取得します。
パブリック プロパティ TimeWritten イベントがログに書き込まれた現地時間を取得します。
パブリック プロパティ UserName イベントを発生させたユーザーの名前を取得します。
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Dispose  Component によって使用されているすべてのリソースを解放します。 (Component から継承されます。)
パブリック メソッド Equals オーバーロードされます。 2 つの項目を比較します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  Component の名前を格納している String を返します (存在する場合)。このメソッドはオーバーライドできません。 (Component から継承されます。)
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Runtime.Serialization.ISerializable.GetObjectData SerializationInfo に、オブジェクトをシリアル化するために必要なデータを設定します。
参照参照

関連項目

EventLogEntry クラス
System.Diagnostics 名前空間
EventLog クラス
EventLogEntryCollection
EventInstance クラス



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「EventLogEntry」の関連用語

EventLogEntryのお隣キーワード
検索ランキング

   

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



EventLogEntryのページの著作権

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

©2026 GRAS Group, Inc.RSS