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

EventLogEntryCollection クラス

EventLogEntry インスタンスコレクションサイズと列挙子定義します

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

Public Class EventLogEntryCollection
    Implements ICollection, IEnumerable
Dim instance As EventLogEntryCollection
public class EventLogEntryCollection : ICollection,
 IEnumerable
public ref class EventLogEntryCollection :
 ICollection, IEnumerable
public class EventLogEntryCollection implements
 ICollection, IEnumerable
public class EventLogEntryCollection implements
 ICollection, IEnumerable
解説解説

EventLogEntryCollection クラスは、EventLog インスタンス関連付けられたエントリを読み取るときに使用しますEventLog クラスEntries プロパティは、イベント ログすべてのエントリのコレクションです。

新しいエントリは既存リスト末尾追加されるため、コレクションを順に処理していけば、最初に EventLogEntryCollection作成した後で作成されたエントリにもアクセスできます。ただし、リスト全体参照した後では、リスト新しいエントリで更新されません。

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

Class EventLogEntryCollection_Item
   Public Shared Sub Main()
      Try
         Dim myLogName As String
 = "MyNewlog"
         ' Check if the source exists.
         If Not EventLog.SourceExists("MySource")
 Then
            'Create source.
            EventLog.CreateEventSource("MySource",
 myLogName)
            Console.WriteLine("Creating EventSource")
         ' Get the EventLog associated if the source exists.
         Else
            myLogName = EventLog.LogNameFromSourceName("MySource",
 ".")
         End If
         ' Create an EventLog instance and assign its source.
         Dim myEventLog2 As New
 EventLog()
         myEventLog2.Source = "MySource"
         ' Write an informational entry to the event log.
         myEventLog2.WriteEntry("Successfully created a new Entry
 in the Log")
         myEventLog2.Close()
         ' Create a new EventLog object.
         Dim myEventLog1 As New
 EventLog()
         myEventLog1.Log = myLogName

         ' Obtain the Log Entries of "MyNewLog".
         Dim myEventLogEntryCollection As EventLogEntryCollection
 = myEventLog1.Entries
         myEventLog1.Close()
         Console.WriteLine("The number of entries in
 'MyNewLog' = " + _
                           myEventLogEntryCollection.Count.ToString())

         ' Display the 'Message' property of EventLogEntry.
         Dim i As Integer
         For i = 0 To myEventLogEntryCollection.Count
 - 1
            Console.WriteLine("The Message of the EventLog is
 :" + _
                              myEventLogEntryCollection(i).Message)
         Next i
         ' Copy the EventLog entries to Array of type EventLogEntry.
         Dim myEventLogEntryArray(myEventLogEntryCollection.Count-1)
 As EventLogEntry
         myEventLogEntryCollection.CopyTo(myEventLogEntryArray, 0)
         Dim myEnumerator As IEnumerator =
 myEventLogEntryArray.GetEnumerator()
         While myEnumerator.MoveNext()
            Dim myEventLogEntry As EventLogEntry
 = CType(myEnumerator.Current, EventLogEntry)
            Console.WriteLine("The LocalTime the Event is generated
 is " + _
                                 myEventLogEntry.TimeGenerated)
         End While
      Catch e As Exception
         Console.WriteLine("Exception:{0}", e.Message.ToString())
      End Try
   End Sub 'Main
End Class 'EventLogEntryCollection_Item
using System;
using System.Collections;
using System.Diagnostics;

class EventLogEntryCollection_Item
{
   public static void Main()
   {
      try
      {
         string myLogName = "MyNewLog";
         // Check if the source exists.
         if(!EventLog.SourceExists("MySource"))
         {
            //Create source.
            EventLog.CreateEventSource("MySource", myLogName);
            Console.WriteLine("Creating EventSource");
         }
         else
            // Get the EventLog associated if the source exists.
            myLogName = EventLog.LogNameFromSourceName("MySource",".");

         // Create an EventLog instance and assign its source.
         EventLog myEventLog2 = new EventLog();
         myEventLog2.Source = "MySource";
         // Write an informational entry to the event log.
         myEventLog2.WriteEntry("Successfully created a new
 Entry in the Log");
         myEventLog2.Close();
         // Create a new EventLog object.
         EventLog myEventLog1 = new EventLog();
         myEventLog1.Log = myLogName;

         // Obtain the Log Entries of "MyNewLog".
         EventLogEntryCollection myEventLogEntryCollection=
            myEventLog1.Entries;
         myEventLog1.Close();
         Console.WriteLine("The number of entries in 'MyNewLog'
 = "
            +myEventLogEntryCollection.Count);

         // Display the 'Message' property of EventLogEntry.
         for(int i=0;i<myEventLogEntryCollection.Count;i++)
         {
            Console.WriteLine("The Message of the EventLog is :"
               +myEventLogEntryCollection[i].Message);
         }

         // Copy the EventLog entries to Array of type EventLogEntry.
         EventLogEntry[] myEventLogEntryArray= 
            new EventLogEntry[myEventLogEntryCollection.Count];
         myEventLogEntryCollection.CopyTo(myEventLogEntryArray,0);
         IEnumerator myEnumerator=myEventLogEntryArray.GetEnumerator();
         while(myEnumerator.MoveNext())
         {
            EventLogEntry myEventLogEntry =(EventLogEntry)myEnumerator.Current;
            Console.WriteLine("The LocalTime the Event is generated is "
               +myEventLogEntry.TimeGenerated);
         }
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception:{0}",e.Message);
      }
   }
}
#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Diagnostics;
int main()
{
   try
   {
      String^ myLogName = "MyNewLog";
      
      // Check if the source exists.
      if (  !EventLog::SourceExists( "MySource" ) )
      {
         //Create source.
         EventLog::CreateEventSource( "MySource", myLogName );
         Console::WriteLine( "Creating EventSource" );
      }
      else
            myLogName = EventLog::LogNameFromSourceName( "MySource", "."
 );
      
      // Get the EventLog associated if the source exists.
      // Create an EventLog instance and assign its source.
      EventLog^ myEventLog2 = gcnew EventLog;
      myEventLog2->Source = "MySource";
      
      // Write an informational entry to the event log.
      myEventLog2->WriteEntry( "Successfully created a new
 Entry in the Log" );
      myEventLog2->Close();
      
      // Create a new EventLog Object*.
      EventLog^ myEventLog1 = gcnew EventLog;
      myEventLog1->Log = myLogName;
      
      // Obtain the Log Entries of S"MyNewLog".
      EventLogEntryCollection^ myEventLogEntryCollection = myEventLog1->Entries;
      myEventLog1->Close();
      Console::WriteLine( "The number of entries in 'MyNewLog'
 = {0}", myEventLogEntryCollection->Count );
      
      // Display the 'Message' property of EventLogEntry.
      for ( int i = 0; i < myEventLogEntryCollection->Count;
 i++ )
      {
         Console::WriteLine( "The Message of the EventLog is : {0}", myEventLogEntryCollection[
 i ]->Message );
      }
      
      // Copy the EventLog entries to Array of type EventLogEntry.
      array<EventLogEntry^>^myEventLogEntryArray = gcnew array<EventLogEntry^>(myEventLogEntryCollection->Count);
      myEventLogEntryCollection->CopyTo( myEventLogEntryArray, 0 );
      IEnumerator^ myEnumerator = myEventLogEntryArray->GetEnumerator();
      while ( myEnumerator->MoveNext() )
      {
         EventLogEntry^ myEventLogEntry = safe_cast<EventLogEntry^>(myEnumerator->Current);
         Console::WriteLine( "The LocalTime the Event is generated is {0}",
 myEventLogEntry->TimeGenerated );
      }
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
import System.*;
import System.Collections.*;
import System.Diagnostics.*;

class EventLogEntryCollectionItem
{
    public static void main(String[]
 args)
    {
        try {
            String myLogName = "MyNewLog";

            // Check if the source exists.
            if (!(EventLog.SourceExists("MySource")))
 {
                //Create source.
                EventLog.CreateEventSource("MySource", myLogName);
                Console.WriteLine("Creating EventSource");
            }
            else {
                // Get the EventLog associated if the source exists.
                myLogName = EventLog.LogNameFromSourceName("MySource",
 ".");
            }

            // Create an EventLog instance and assign its source.
            EventLog myEventLog2 = new EventLog();
            myEventLog2.set_Source("MySource");

            // Write an informational entry to the event log.
            myEventLog2.WriteEntry("Successfully created a new
 Entry in "
                + "the Log");
            myEventLog2.Close();

            // Create a new EventLog object.
            EventLog myEventLog1 = new EventLog();
            myEventLog1.set_Log(myLogName);

            // Obtain the Log Entries of "MyNewLog".
            EventLogEntryCollection myEventLogEntryCollection = 
                myEventLog1.get_Entries();

            myEventLog1.Close();
            Console.WriteLine("The number of entries in 'MyNewLog'
 = " 
                + myEventLogEntryCollection.get_Count());

            // Display the 'Message' property of EventLogEntry.
            for (int i = 0; i < myEventLogEntryCollection.get_Count();
 i++) {
                Console.WriteLine("The Message of the EventLog is :"
                    + myEventLogEntryCollection.get_Item(i).get_Message());
            }
            // Copy the EventLog entries to Array of type EventLogEntry.
            EventLogEntry myEventLogEntryArray[] = 
                new EventLogEntry[myEventLogEntryCollection.get_Count()];

            myEventLogEntryCollection.CopyTo(myEventLogEntryArray, 0);
            IEnumerator myEnumerator = myEventLogEntryArray.GetEnumerator();
            while (myEnumerator.MoveNext()) {
                EventLogEntry myEventLogEntry = 
                    (EventLogEntry)myEnumerator.get_Current();
                Console.WriteLine("The LocalTime the Event is generated is "
 
                    + myEventLogEntry.get_TimeGenerated());
            }
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception:{0}", e.get_Message());
        }
    } //main
} //EventLogEntryCollectionItem
継承階層継承階層
System.Object
  System.Diagnostics.EventLogEntryCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventLogEntryCollection メンバ
System.Diagnostics 名前空間
EventLog クラス
EventLog.Entries プロパティ

EventLogEntryCollection プロパティ


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

  名前 説明
パブリック プロパティ Count イベント ログのエントリ数 (EventLogEntry コレクション内の要素数) を取得します
パブリック プロパティ Item 0 から始まるインデックス基づいてイベント ログのエントリを取得します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.IsSynchronized EventLogEntryCollection へのアクセス同期されている (スレッド セーフである) かどうかを示す値を取得します
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot EventLogEntryCollection へのアクセス同期するために使用できるオブジェクト取得します
参照参照

関連項目

EventLogEntryCollection クラス
System.Diagnostics 名前空間
EventLog クラス
EventLog.Entries プロパティ

EventLogEntryCollection メソッド


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

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo コレクション要素ArrayコピーしますArray特定のインデックスからコピー開始されます。
参照参照

関連項目

EventLogEntryCollection クラス
System.Diagnostics 名前空間
EventLog クラス
EventLog.Entries プロパティ

EventLogEntryCollection メンバ

EventLogEntry インスタンスコレクションサイズと列挙子定義します

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


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Count イベント ログのエントリ数 (EventLogEntry コレクション内の要素数) を取得します
パブリック プロパティ Item 0 から始まるインデックス基づいてイベント ログのエントリを取得します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo コレクション要素ArrayコピーしますArray特定のインデックスからコピー開始されます。
インターフェイスの明示的な実装 System.Collections.ICollection.IsSynchronized EventLogEntryCollection へのアクセス同期されている (スレッド セーフである) かどうかを示す値を取得します
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot EventLogEntryCollection へのアクセス同期するために使用できるオブジェクト取得します
参照参照

関連項目

EventLogEntryCollection クラス
System.Diagnostics 名前空間
EventLog クラス
EventLog.Entries プロパティ



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

辞書ショートカット

すべての辞書の索引

「EventLogEntryCollection」の関連用語

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

   

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



EventLogEntryCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS