EventSourceCreationData.Source 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이벤트 로그에 이벤트 원본으로 등록할 이름을 가져오거나 설정합니다.
public:
property System::String ^ Source { System::String ^ get(); void set(System::String ^ value); };
public string Source { get; set; }
member this.Source : string with get, set
Public Property Source As String
속성 값
이벤트 로그에 항목의 원본으로 등록할 이름입니다. 기본값은 빈 문자열("")입니다.
예제
다음 코드 예제에서는 명령줄 인수에서 이벤트 소스에 대 한 구성 속성을 설정 합니다. 입력 인수는 이벤트 원본 이름, 이벤트 로그 이름, 컴퓨터 이름 및 이벤트 메시지 리소스 파일을 지정합니다. 이 예제는 클래스에 제공된 더 큰 예제의 EventSourceCreationData 일부입니다.
EventSourceCreationData mySourceData = new EventSourceCreationData("", "");
bool registerSource = true;
// Process input parameters.
if (args.Length > 0)
{
// Require at least the source name.
mySourceData.Source = args[0];
if (args.Length > 1)
{
mySourceData.LogName = args[1];
}
if (args.Length > 2)
{
mySourceData.MachineName = args[2];
}
if ((args.Length > 3) && (args[3].Length > 0))
{
mySourceData.MessageResourceFile = args[3];
}
}
else
{
// Display a syntax help message.
Console.WriteLine("Input:");
Console.WriteLine(" source [event log] [machine name] [resource file]");
registerSource = false;
}
// Set defaults for parameters missing input.
if (mySourceData.MachineName.Length == 0)
{
// Default to the local computer.
mySourceData.MachineName = ".";
}
if (mySourceData.LogName.Length == 0)
{
// Default to the Application log.
mySourceData.LogName = "Application";
}
Dim mySourceData As EventSourceCreationData = new EventSourceCreationData("", "")
Dim registerSource As Boolean = True
' Process input parameters.
If args.Length > 0
' Require at least the source name.
mySourceData.Source = args(0)
If args.Length > 1
mySourceData.LogName = args(1)
End If
If args.Length > 2
mySourceData.MachineName = args(2)
End If
If args.Length > 3 AndAlso args(3).Length > 0
mySourceData.MessageResourceFile = args(3)
End If
Else
' Display a syntax help message.
Console.WriteLine("Input:")
Console.WriteLine(" source [event log] [machine name] [resource file]")
registerSource = False
End If
' Set defaults for parameters missing input.
If mySourceData.MachineName.Length = 0
' Default to the local computer.
mySourceData.MachineName = "."
End If
If mySourceData.LogName.Length = 0
' Default to the Application log.
mySourceData.LogName = "Application"
End If
설명
원본 이름은 종종 애플리케이션의 이름 또는 큰 애플리케이션 내의 구성 요소 이름입니다. 메서드는 EventLog.CreateEventSource(EventSourceCreationData) , LogName및 MachineName 속성을 사용하여 Source대상 컴퓨터에서 새 원본 및 관련 이벤트 로그에 대한 레지스트리 값을 만듭니다. 새 원본 이름은 대상 컴퓨터의 기존 원본 이름 또는 기존 이벤트 로그 이름과 일치할 수 없습니다.
원본에 대한 레지스트리 값을 만든 후 애플리케이션은 원본을 사용하여 구성된 이벤트 로그에 항목을 쓸 수 있습니다.
각 원본은 한 번에 하나의 이벤트 로그에만 쓸 수 있습니다. 그러나 애플리케이션은 여러 원본을 사용하여 여러 이벤트 로그에 쓸 수 있습니다. 예를 들어 애플리케이션에는 여러 이벤트 로그 또는 다른 리소스 파일에 대해 구성된 여러 원본이 필요할 수 있습니다.