Share via


EventSourceCreationData.Source 속성

정의

이벤트 로그에 이벤트 소스로 등록할 이름을 가져오거나 설정합니다.

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 = gcnew EventSourceCreationData( "","" );
bool registerSource = true;

// Process input parameters.
if ( args->Length > 1 )
{
   
   // Require at least the source name.
   mySourceData->Source = args[ 1 ];
   if ( args->Length > 2 )
   {
      mySourceData->LogName = args[ 2 ];
   }

   if ( args->Length > 3 )
   {
      mySourceData->MachineName = args[ 3 ];
   }

   if ( (args->Length > 4) && (args[ 4 ]->Length > 0) )
   {
      mySourceData->MessageResourceFile = args[ 4 ];
   }
}
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";
}
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및 속성을 사용하여 Source새 원본 및 MachineName 관련 이벤트 로그에 대한 대상 컴퓨터에 레지스트리 값을 만듭니다. 새 원본 이름은 대상 컴퓨터의 기존 원본 이름 또는 기존 이벤트 로그 이름과 일치할 수 없습니다.

원본에 대 한 레지스트리 값을 만든 후 애플리케이션 구성된 된 이벤트 로그에 엔트리를 쓸 원본을 사용할 수 있습니다.

각 소스에서는 한 번에 하나의 이벤트 로그에 쓸 수 있습니다만 그러나 애플리케이션이 여러 이벤트 로그에 쓸 여러 원본을 사용할 수 있습니다. 예를 들어, 애플리케이션에 다른 이벤트 로그 또는 다른 리소스 파일에 대해 구성 된 여러 소스가 필요할 수 있습니다.

적용 대상

추가 정보