EventLog Oluşturucular
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
EventLog sınıfının yeni bir örneğini başlatır.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| EventLog() |
EventLog sınıfının yeni bir örneğini başlatır. Örneği herhangi bir günlükle ilişkilendirmez. |
| EventLog(String) |
EventLog sınıfının yeni bir örneğini başlatır. Örneği yerel bilgisayardaki bir günlükle ilişkilendirir. |
| EventLog(String, String) |
EventLog sınıfının yeni bir örneğini başlatır. Örneği belirtilen bilgisayardaki bir günlükle ilişkilendirir. |
| EventLog(String, String, String) |
EventLog sınıfının yeni bir örneğini başlatır. Örneği belirtilen bilgisayarda bir günlükle ilişkilendirir ve belirtilen kaynağı oluşturur veya öğesine EventLogatar. |
EventLog()
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
EventLog sınıfının yeni bir örneğini başlatır. Örneği herhangi bir günlükle ilişkilendirmez.
public:
EventLog();
public EventLog();
Public Sub New ()
Örnekler
Aşağıdaki örnek, henüz yoksa kaynağı MySource oluşturur ve olay günlüğüne MyNewLogbir girdi yazar.
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"))
{
//An event log source should not be created and immediately used.
//There is a latency time to enable the source, it should be created
//prior to executing the application that uses the source.
//Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatedEventSource");
Console.WriteLine("Exiting, execute the application a second time to use the source.");
// The source is created. Exit the application to allow it to be registered.
return;
}
// 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.");
}
}
Option Explicit
Option Strict
Imports System.Diagnostics
Imports System.Threading
Class MySample
Public Shared Sub Main()
If Not EventLog.SourceExists("MySource") Then
' Create the source, if it does not already exist.
' An event log source should not be created and immediately used.
' There is a latency time to enable the source, it should be created
' prior to executing the application that uses the source.
' Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog")
Console.WriteLine("CreatingEventSource")
'The source is created. Exit the application to allow it to be registered.
Return
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
End Class
Açıklamalar
çağrısından WriteEntryönce örneğin özelliğini EventLog belirtinSource. Yalnızca günlükten okuyorsanız Entries , alternatif olarak yalnızca Log ve MachineName özelliklerini belirtebilirsiniz.
Uyarı
belirtmezseniz MachineName, yerel bilgisayar (".") varsayılır.
Aşağıdaki tabloda, örneğinin ilk özellik değerleri gösterilmektedir EventLog.
| Mülkiyet | İlk Değer |
|---|---|
| Source | Boş bir dize (""). |
| Log | Boş bir dize (""). |
| MachineName | Yerel bilgisayar ("."). |
Ayrıca bkz.
Şunlara uygulanır
EventLog(String)
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
EventLog sınıfının yeni bir örneğini başlatır. Örneği yerel bilgisayardaki bir günlükle ilişkilendirir.
public:
EventLog(System::String ^ logName);
public EventLog(string logName);
new System.Diagnostics.EventLog : string -> System.Diagnostics.EventLog
Public Sub New (logName As String)
Parametreler
- logName
- String
Yerel bilgisayardaki günlüğün adı.
Özel durumlar
Günlük adı şeklindedir null.
Günlük adı geçersiz.
Örnekler
Aşağıdaki örnek, yerel bilgisayardaki "myNewLog" olay günlüğündeki girdileri okur.
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"))
{
//An event log source should not be created and immediately used.
//There is a latency time to enable the source, it should be created
//prior to executing the application that uses the source.
//Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatedEventSource");
Console.WriteLine("Exiting, execute the application a second time to use the source.");
// The source is created. Exit the application to allow it to be registered.
return;
}
// 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);
}
}
}
Option Explicit
Option Strict
Imports System.Diagnostics
Imports System.Threading
Class MySample
Public Shared Sub Main()
If Not EventLog.SourceExists("MySource") Then
' Create the source, if it does not already exist.
' An event log source should not be created and immediately used.
' There is a latency time to enable the source, it should be created
' prior to executing the application that uses the source.
' Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog")
Console.WriteLine("CreatingEventSource")
'The source is created. Exit the application to allow it to be registered.
Return
End If
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
End Class
Açıklamalar
Bu aşırı yükleme özelliği parametresine logName ayarlarLog. çağrısından WriteEntryönce örneğin özelliğini EventLog belirtinSource. Yalnızca günlükten okuyorsanız Entries , alternatif olarak yalnızca Log ve MachineName özelliklerini belirtebilirsiniz.
Uyarı
belirtmezseniz MachineName, yerel bilgisayar (".") varsayılır. Oluşturucunun bu aşırı yüklemesi özelliğini belirtir Log , ancak özelliği okumadan Entries önce bunu değiştirebilirsiniz.
Özelliğinde Source belirttiğiniz kaynak bilgisayardaki diğer kaynaklardan benzersizse, sonraki bir çağrı WriteEntry belirtilen ada sahip bir günlük oluşturur (yoksa).
Aşağıdaki tabloda, örneğinin ilk özellik değerleri gösterilmektedir EventLog.
| Mülkiyet | İlk Değer |
|---|---|
| Source | Boş bir dize (""). |
| Log |
logName parametresi. |
| MachineName | Yerel bilgisayar ("."). |
Ayrıca bkz.
Şunlara uygulanır
EventLog(String, String)
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
EventLog sınıfının yeni bir örneğini başlatır. Örneği belirtilen bilgisayardaki bir günlükle ilişkilendirir.
public:
EventLog(System::String ^ logName, System::String ^ machineName);
public EventLog(string logName, string machineName);
new System.Diagnostics.EventLog : string * string -> System.Diagnostics.EventLog
Public Sub New (logName As String, machineName As String)
Parametreler
- logName
- String
Belirtilen bilgisayardaki günlüğün adı.
- machineName
- String
Günlüğün bulunduğu bilgisayar.
Özel durumlar
Günlük adı şeklindedir null.
Örnekler
Aşağıdaki örnek, "myServer" bilgisayarındaki "myNewLog" olay günlüğündeki girdileri okur.
using System;
using System.Diagnostics;
using System.Threading;
class MySample1
{
public static void Main()
{
// Create the source, if it does not already exist.
if (!EventLog.SourceExists("MySource"))
{
//An event log source should not be created and immediately used.
//There is a latency time to enable the source, it should be created
//prior to executing the application that uses the source.
//Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog", "myServer");
Console.WriteLine("CreatedEventSource");
Console.WriteLine("Exiting, execute the application a second time to use the source.");
// The source is created. Exit the application to allow it to be registered.
return;
}
// 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);
}
}
}
Option Explicit
Option Strict
Imports System.Diagnostics
Imports System.Threading
Class MySample
Public Shared Sub Main()
If Not EventLog.SourceExists("MySource") Then
' Create the source, if it does not already exist.
' An event log source should not be created and immediately used.
' There is a latency time to enable the source, it should be created
' prior to executing the application that uses the source.
' Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog", "myServer")
Console.WriteLine("CreatingEventSource")
'The source is created. Exit the application to allow it to be registered.
Return
End If
' 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
End Class
Açıklamalar
Bu aşırı yükleme özelliği parametresine logName ve MachineName özelliği parametresine machineName ayarlarLog. çağrısından WriteEntryönce özelliğini EventLogbelirtinSource. Yalnızca günlükten okuyorsanız Entries , alternatif olarak yalnızca Log ve MachineName özelliklerini belirtebilirsiniz.
Uyarı
Oluşturucunun bu aşırı yüklemesi ve MachineName özelliklerini belirtirLog, ancak özelliği okumadan Entries önce değiştirebilirsiniz.
Aşağıdaki tabloda, örneğinin ilk özellik değerleri gösterilmektedir EventLog.
| Mülkiyet | İlk Değer |
|---|---|
| Source | Boş bir dize (""). |
| Log |
logName parametresi. |
| MachineName |
machineName parametresi. |
Ayrıca bkz.
Şunlara uygulanır
EventLog(String, String, String)
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
- Kaynak:
- EventLog.cs
public:
EventLog(System::String ^ logName, System::String ^ machineName, System::String ^ source);
public EventLog(string logName, string machineName, string source);
new System.Diagnostics.EventLog : string * string * string -> System.Diagnostics.EventLog
Public Sub New (logName As String, machineName As String, source As String)
Parametreler
- logName
- String
Belirtilen bilgisayardaki günlüğün adı.
- machineName
- String
Günlüğün bulunduğu bilgisayar.
- source
- String
Olay günlüğü girdilerinin kaynağı.
Özel durumlar
Günlük adı şeklindedir null.
Örnekler
Aşağıdaki örnek, "MySource" kaynağını kullanarak yerel bilgisayarda "MyNewLog" adlı bir olay günlüğüne bir girdi yazar.
using System;
using System.Diagnostics;
using System.Threading;
class MySample2
{
public static void Main()
{
// Create the source, if it does not already exist.
if (!EventLog.SourceExists("MySource"))
{
//An event log source should not be created and immediately used.
//There is a latency time to enable the source, it should be created
//prior to executing the application that uses the source.
//Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatedEventSource");
Console.WriteLine("Exiting, execute the application a second time to use the source.");
// The source is created. Exit the application to allow it to be registered.
return;
}
// 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);
}
}
Option Strict
Option Explicit
Imports System.Diagnostics
Imports System.Threading
Class MySample
Public Shared Sub Main()
If Not EventLog.SourceExists("MySource") Then
' Create the source, if it does not already exist.
' An event log source should not be created and immediately used.
' There is a latency time to enable the source, it should be created
' prior to executing the application that uses the source.
' Execute this sample a second time to use the new source.
EventLog.CreateEventSource("MySource", "MyNewLog")
Console.WriteLine("CreatingEventSource")
'The source is created. Exit the application to allow it to be registered.
Return
End If
' 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
End Class
Açıklamalar
Bu oluşturucu özelliği parametresine, özelliği parametresine machineName ve Source özelliğini parametresine source ayarlarLog.MachineNamelogName
Source Özelliği bir olay günlüğüne yazılırken gereklidir. Ancak, yalnızca bir olay günlüğünden okuyorsanız, yalnızca Log ve MachineName özellikleri gereklidir (sunucudaki olay günlüğünün kendisiyle zaten ilişkilendirilmiş bir kaynağı olduğu sürece). Yalnızca olay günlüğünden okuyorsanız oluşturucunun başka bir aşırı yüklemesi yeterli olabilir.
Aşağıdaki tabloda, örneğinin ilk özellik değerleri gösterilmektedir EventLog.
| Mülkiyet | İlk Değer |
|---|---|
| Source |
source parametresi. |
| Log |
logName parametresi. |
| MachineName |
machineName parametresi. |