EventLog コンストラクタ ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > EventLog コンストラクタ ()の意味・解説 

EventLog コンストラクタ ()

EventLog クラス新しインスタンス初期化します。このインスタンスは、ログとは関連付けられません。

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

解説解説
使用例使用例

ソース存在しない場合MySource作成しイベント ログ MyNewLogエントリ書き込む例を次に示します

Option Explicit
Option Strict

Imports System
Imports System.Diagnostics
Imports System.Threading

Class MySample
    Public Shared Sub Main()
        
        ' Create the source, if it does not already exist.
        If Not EventLog.SourceExists("MySource")
 Then
            EventLog.CreateEventSource("MySource",
 "MyNewLog")
            Console.WriteLine("CreatingEventSource")
        End If
        
        ' Create an EventLog instance and assign its source.
        Dim myLog As New
 EventLog()
        myLog.Source = "MySource"
        
        ' Write an informational entry to the event log.    
        myLog.WriteEntry("Writing to event log.")
    End Sub 'Main 
End Class 'MySample
using System;
using System.Diagnostics;
using System.Threading;
              
class MySample{

    public static void Main(){
    
        // Create the source, if it does not already exist.
        if(!EventLog.SourceExists("MySource")){
            EventLog.CreateEventSource("MySource", "MyNewLog");
            Console.WriteLine("CreatingEventSource");
        }
                
        // Create an EventLog instance and assign its source.
        EventLog myLog = new EventLog();
        myLog.Source = "MySource";
        
        // Write an informational entry to the event log.    
        myLog.WriteEntry("Writing to event log.");
        
    }
}
   
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main()
{
   
   // Create the source, if it does not already exist.
   if (  !EventLog::SourceExists( "MySource" ) )
   {
      EventLog::CreateEventSource( "MySource", "MyNewLog" );
      Console::WriteLine( "CreatingEventSource" );
   }

   
   // Create an EventLog instance and assign its source.
   EventLog^ myLog = gcnew EventLog;
   myLog->Source = "MySource";
   
   // Write an informational entry to the event log.    
   myLog->WriteEntry( "Writing to event log." );
}

import System.*;
import System.Diagnostics.*;
import System.Threading.*;

class MySample
{
    public static void main(String[]
 args)
    {
        // Create the source, if it does not already exist.
        if (!(EventLog.SourceExists("MySource"))) {
            EventLog.CreateEventSource("MySource", "MyNewLog");
            Console.WriteLine("CreatingEventSource");
        }

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

        // Write an informational entry to the event log.    
        myLog.WriteEntry("Writing to event log.");
    } //main 
} //MySample
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventLog クラス
EventLog メンバ
System.Diagnostics 名前空間
Source
Log
MachineName
Entries
WriteEntry
WriteEvent
EventLogEntry

EventLog コンストラクタ (String, String)

EventLog クラス新しインスタンス初期化します。指定したコンピュータ上のログインスタンス関連付けます。

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

Public Sub New ( _
    logName As String, _
    machineName As String _
)
Dim logName As String
Dim machineName As String

Dim instance As New EventLog(logName,
 machineName)
public EventLog (
    string logName,
    string machineName
)
public:
EventLog (
    String^ logName, 
    String^ machineName
)
public EventLog (
    String logName, 
    String machineName
)
public function EventLog (
    logName : String, 
    machineName : String
)

パラメータ

logName

指定したコンピュータ上のログの名前。

machineName

ログ存在するコンピュータ

例外例外
例外種類条件

ArgumentNullException

ログ名が null 参照 (Visual Basic では Nothing) です。

ArgumentException

ログ名が無効です。

または

コンピュータ名が無効です。

解説解説
使用例使用例

コンピュータ "myServer" 上のイベント ログ "myNewLog" のエントリ読み取る例を次に示します

Option Explicit
Option Strict

Imports System
Imports System.Diagnostics
Imports System.Threading
Imports Microsoft.VisualBasic

Class MySample
    Public Shared Sub Main()
        
        ' Create an EventLog instance and assign its log name.
        Dim myLog As New
 EventLog("myNewLog", "myServer")
        
        ' Read the event log entries.
        Dim entry As EventLogEntry
        For Each entry In
  myLog.Entries
            Console.WriteLine((ControlChars.Tab & "Entry:
 " & entry.Message))
        Next entry
    End Sub ' Main
End Class ' MySample
using System;
using System.Diagnostics;
using System.Threading;
              
class MySample{

    public static void Main(){
         
        // Create an EventLog instance and assign its log name.
        EventLog myLog = new EventLog("myNewLog", "myServer");

        // Read the event log entries.
        foreach(EventLogEntry entry in myLog.Entries){
            Console.WriteLine("\tEntry: " + entry.Message);
        }                                                                     
    } 
}
   
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main()
{
   
   // Create an EventLog instance and assign its log name.
   EventLog^ myLog = gcnew EventLog( "myNewLog","myServer" );
   
   // Read the event log entries.
   System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      EventLogEntry^ entry = safe_cast<EventLogEntry^>(myEnum->Current);
      Console::WriteLine( "\tEntry: {0}", entry->Message );
   }
}

import System.*;
import System.Diagnostics.*;
import System.Threading.*;

class MySample
{
    public static void main(String[]
 args)
    {
        // Create an EventLog instance and assign its log name.
        EventLog myLog = new EventLog("myNewLog", "myServer");
        // Read the event log entries.
        for (int iCtr = 0; iCtr < myLog.get_Entries().get_Count();
 iCtr++) {
            EventLogEntry entry = myLog.get_Entries().get_Item(iCtr);
            Console.WriteLine("\tEntry: " + entry.get_Message());
        }
    } //main
} //MySample
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventLog クラス
EventLog メンバ
System.Diagnostics 名前空間
Source
Log
MachineName
Entries
WriteEntry
WriteEvent
EventLogEntry

EventLog コンストラクタ (String)

EventLog クラス新しインスタンス初期化します。ローカル コンピュータ上のログインスタンス関連付けます。

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

Public Sub New ( _
    logName As String _
)
Dim logName As String

Dim instance As New EventLog(logName)
public EventLog (
    string logName
)
public:
EventLog (
    String^ logName
)
public EventLog (
    String logName
)
public function EventLog (
    logName : String
)

パラメータ

logName

ローカル コンピュータ上のログの名前。

例外例外
例外種類条件

ArgumentNullException

ログ名が null 参照 (Visual Basic では Nothing) です。

ArgumentException

ログ名が無効です。

解説解説
使用例使用例

ローカル コンピュータ上のイベント ログ "myNewLog" のエントリ読み取る例を次に示します

Option Explicit
Option Strict

Imports System
Imports System.Diagnostics
Imports System.Threading
Imports Microsoft.VisualBasic

Class MySample
    Public Shared Sub Main()
        
        ' Create an EventLog instance and assign its log name.
        Dim myLog As New
 EventLog("myNewLog")
        
        ' Read the event log entries.
        Dim entry As EventLogEntry
        For Each entry In
  myLog.Entries
            Console.WriteLine((ControlChars.Tab & "Entry:
 " & entry.Message))
        Next entry
    End Sub ' Main
End Class ' MySample
using System;
using System.Diagnostics;
using System.Threading;
              
class MySample{


    public static void Main(){
           
                        
        // Create an EventLog instance and assign its log name.
        EventLog myLog = new EventLog("myNewLog");

        // Read the event log entries.
        foreach(EventLogEntry entry in myLog.Entries){
            Console.WriteLine("\tEntry: " + entry.Message);
        }                                                                     
    }
}
   
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main()
{
   
   // Create an EventLog instance and assign its log name.
   EventLog^ myLog = gcnew EventLog( "myNewLog" );
   
   // Read the event log entries.
   System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      EventLogEntry^ entry = safe_cast<EventLogEntry^>(myEnum->Current);
      Console::WriteLine( "\tEntry: {0}", entry->Message );
   }
}

import System.*;
import System.Diagnostics.*;
import System.Threading.*;

class MySample
{
    public static void main(String[]
 args)
    {
        // Create an EventLog instance and assign its log name.
        EventLog myLog = new EventLog("myNewLog");

        // Read the event log entries.
        for (int iCtr = 0; iCtr < myLog.get_Entries().get_Count();
 iCtr++) {
            EventLogEntry entry = myLog.get_Entries().get_Item(iCtr);
            Console.WriteLine("\tEntry: " + entry.get_Message());
        }
    } //main
} //MySample
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventLog クラス
EventLog メンバ
System.Diagnostics 名前空間
Source
Log
MachineName
Entries
WriteEntry
WriteEvent
EventLogEntry

EventLog コンストラクタ


EventLog コンストラクタ (String, String, String)

EventLog クラス新しインスタンス初期化します。指定したコンピュータ上のログインスタンス関連付け指定したソース作成するか、または EventLog割り当てます

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

Public Sub New ( _
    logName As String, _
    machineName As String, _
    source As String _
)
Dim logName As String
Dim machineName As String
Dim source As String

Dim instance As New EventLog(logName,
 machineName, source)
public EventLog (
    string logName,
    string machineName,
    string source
)
public:
EventLog (
    String^ logName, 
    String^ machineName, 
    String^ source
)
public EventLog (
    String logName, 
    String machineName, 
    String source
)
public function EventLog (
    logName : String, 
    machineName : String, 
    source : String
)

パラメータ

logName

指定したコンピュータ上のログの名前。

machineName

ログ存在するコンピュータ

source

イベント ログ エントリソース

例外例外
例外種類条件

ArgumentNullException

ログ名が null 参照 (Visual Basic では Nothing) です。

ArgumentException

ログ名が無効です。

または

コンピュータ名が無効です。

解説解説
使用例使用例

ソース "MySource" を使用してローカル コンピュータ上のイベント ログ "MyNewLog" にエントリ書き込む例を次に示します

Option Strict
Option Explicit

Imports System
Imports System.Diagnostics
Imports System.Threading

Class MySample
    Public Shared Sub Main()
        
        ' Create an EventLog instance and assign its source.
        Dim myLog As New
 EventLog("myNewLog", ".",
 "MySource")
        
        ' Write an entry to the log.        
        myLog.WriteEntry(("Writing to event log on "
 & myLog.MachineName))
    End Sub ' Main 
End Class ' MySample
using System;
using System.Diagnostics;
using System.Threading;
              
class MySample{

    public static void Main(){
         
        // Create an EventLog instance and assign its source.
        EventLog myLog = new EventLog("myNewLog", ".",
 "MySource");

        // Write an entry to the log.        
        myLog.WriteEntry("Writing to event log on " + myLog.MachineName);

    }
}
   
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main()
{
   
   // Create an EventLog instance and assign its source.
   EventLog^ myLog = gcnew EventLog( "myNewLog",".","MySource"
 );
   
   // Write an entry to the log.        
   myLog->WriteEntry( String::Format( "Writing to event log on {0}",
 myLog->MachineName ) );
}

import System.*;
import System.Diagnostics.*;
import System.Threading.*;

class MySample
{
    public static void main(String[]
 args)
    {
        // Create an EventLog instance and assign its source.
        EventLog myLog = new EventLog("myNewLog", ".",
 "MySource");
        // Write an entry to the log.        
        myLog.WriteEntry("Writing to event log on " 
            + myLog.get_MachineName());
    } //main 
} //MySample
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventLog クラス
EventLog メンバ
System.Diagnostics 名前空間
Source
Log
MachineName
Entries
WriteEntry
WriteEvent
EventLogEntry



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

辞書ショートカット

すべての辞書の索引

「EventLog コンストラクタ ()」の関連用語

EventLog コンストラクタ ()のお隣キーワード
検索ランキング

   

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



EventLog コンストラクタ ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS