EventSourceCreationData.LogName プロパティ

定義

ソースがエントリを書き込むイベント ログの名前を取得または設定します。

public:
 property System::String ^ LogName { System::String ^ get(); void set(System::String ^ value); };
public string LogName { get; set; }
member this.LogName : string with get, set
Public Property LogName As String

プロパティ値

イベント ログの名前。 ログ名には、アプリケーション ログ名、システム ログ名、またはカスタム ログ名を指定できます。 既定値は "Application" です。

次のコード例では、コマンド ライン引数からイベント ソースの構成プロパティを設定します。 入力引数は、イベント ソース名、イベント ログ名、コンピューター名、およびイベント メッセージ リソース ファイルを指定します。 この例は、 クラスに対して提供されるより大きな例の 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

注釈

プロパティを LogName 使用して、アプリケーションが新しいソースを使用してエントリを書き込むイベント ログを特定します。 イベント ログには、新しいログまたは既存のログを指定できます。 アプリケーションとサービスは、アプリケーション ログまたはカスタム ログに書き込む必要があります。 デバイス ドライバーは、システム ログに書き込む必要があります。 プロパティを明示的に設定しない場合、イベント ログは既定でアプリケーション ログに設定 LogName されます。

注意

セキュリティ ログは読み取り専用です。

新しいソースの既存のログをターゲットにするには、 プロパティを LogName 既存のイベント ログ名に設定します。 ソースの新しいイベント ログを作成するには、 プロパティを設定する LogName 必要があります。 イベント ログ名は印刷可能な文字で構成する必要があり、文字 '*'、'?'、または '\' を含めることはできません。 イベント ログ名の最初の 8 文字は、指定したコンピューター上のイベント ログの既存の名前の最初の 8 文字とは異なる必要があります。

オペレーティング システムではイベント ログはファイルとして保存されます。 または メソッドをCreateEventSource使用EventLogInstallerして新しいイベント ログを作成すると、関連付けられたファイルは、指定したコンピューターの %SystemRoot%\System32\Config ディレクトリに格納されます。 ファイル名は、プロパティの最初の 8 文字 LogName に ".evt" ファイル名拡張子を付加することによって設定されます。

適用対象

こちらもご覧ください