EventLogEntry.Source 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 이벤트를 생성한 애플리케이션의 이름을 가져옵니다.
public:
property System::String ^ Source { System::String ^ get(); };
public string Source { get; }
member this.Source : string
Public ReadOnly Property Source As String
속성 값
이 이벤트의 원본으로 이벤트 로그에 등록된 이름입니다.
예제
다음 코드 예제에서는 속성의 사용을 보여 줍니다 Source . 이 예제에서 문은 switch 콘솔 입력을 사용하여 지정된 EntryType이벤트 로그 항목을 검색합니다. 일치하는 항목이 발견 Source 되면 속성 정보가 콘솔에 표시됩니다.
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>-1;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;
}
}
}
}
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 0 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
End Sub
End Class
설명
이벤트 원본은 이벤트를 기록한 내용을 나타냅니다. 애플리케이션이 큰 경우 애플리케이션의 이름 또는 애플리케이션의 하위 구성 요소 이름인 경우가 많습니다. 애플리케이션 및 서비스는 일반적으로 애플리케이션 로그 또는 사용자 지정 로그에 쓰기(따라서 원본)입니다. 디바이스 드라이버는 일반적으로 시스템 로그에 씁니다.