EventSourceCreationData.Source Özellik

Tanım

Olay günlüğüyle bir olay kaynağı olarak kaydedilecek adı alır veya ayarlar.

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

Özellik Değeri

Giriş kaynağı olarak olay günlüğüne kaydedilecek ad. Varsayılan değer, boş dizedir ("").

Örnekler

Aşağıdaki kod örneği, komut satırı bağımsız değişkenlerinden bir olay kaynağının yapılandırma özelliklerini ayarlar. Giriş bağımsız değişkenleri olay kaynağı adını, olay günlüğü adını, bilgisayar adını ve olay iletisi kaynak dosyasını belirtir. Bu örnek, sınıfı için EventSourceCreationData sağlanan daha büyük bir örneğin parçasıdır.

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

Açıklamalar

Kaynak adı genellikle uygulamanın adı veya büyük bir uygulama içindeki bir bileşenin adıdır. yöntemi, EventLog.CreateEventSource(EventSourceCreationData) hedef bilgisayarda yeni kaynak ve MachineName ilişkili olay günlüğü için kayıt defteri değerleri oluşturmak üzere , LogNameve özelliklerini kullanırSource. Yeni bir kaynak adı, hedef bilgisayardaki var olan bir kaynak adı veya var olan bir olay günlüğü adıyla eşleşemez.

Kaynak için kayıt defteri değerleri oluşturulduktan sonra, uygulamanız yapılandırılan olay günlüğüne girdi yazmak için kaynağı kullanabilir.

Her kaynak aynı anda yalnızca bir olay günlüğüne yazabilir; ancak uygulamanız birden çok olay günlüğüne yazmak için birden çok kaynak kullanabilir. Örneğin, uygulamanız farklı olay günlükleri veya farklı kaynak dosyaları için yapılandırılmış birden çok kaynak gerektirebilir.

Şunlara uygulanır

Ayrıca bkz.