イベント ログの表示名を取得します。
Public ReadOnly Property LogDisplayName As String
[C#]
public string LogDisplayName {get;}
[C++]
public: __property String* get_LogDisplayName();
[JScript]
public function get LogDisplayName() : String;
プロパティ値
システムのイベント ビューアのイベント ログを表す名前。
例外
例外の種類 | 条件 |
---|---|
Exception | MachineName プロパティで指定されたコンピュータにはログがありません。 |
SystemException | このイベント ログに関連付けられたレジストリ キーをアプリケーションで開くことができませんでした。 |
使用例
Dim myRemoteMachine As String
Dim myLogName as string = "MyLog"
Console.Write("Enter computer on which to create log : ")
myRemoteMachine = Console.ReadLine()
' Check if the source exists.
if not EventLog.SourceExists("MyTestSource") then
'Create source.
EventLog.CreateEventSource("MyTestSource", myLogName,myRemoteMachine)
Console.WriteLine("Creating EventSource")
else
'Get the EventLog associated if the source exists.
myLogName = EventLog.LogNameFromSourceName("MyTestSource",myRemoteMachine)
end if
Dim myEventLog1 As New EventLog(myLogName, myRemoteMachine)
myEventLog1.Source = "MyTestSource"
' Write an entry into log.
myEventLog1.WriteEntry("This is for your information", _
EventLogEntryType.SuccessAudit, 100)
Console.WriteLine("An EventLog created on computer " + myEventLog1.MachineName)
Console.Write("Enter remote computer on which to create log : ")
myRemoteMachine = Console.ReadLine()
Dim myEventLog2 As New EventLog()
myEventLog2.MachineName = myRemoteMachine
myEventLog2.Source = "MyTestSource"
myEventLog2.Log = myEventLog1.LogDisplayName
myEventLog2.WriteEntry("This is for your information")
Console.WriteLine("An EventLog created on computer " + myEventLog2.MachineName)
[C#]
string myRemoteMachine;
string myLogName = "MyLog";
Console.Write( "Enter computer on which to create log : " );
myRemoteMachine = Console.ReadLine();
// Check if the source exists.
if(!EventLog.SourceExists("MyTestSource"))
{
//Create source.
EventLog.CreateEventSource("MyTestSource", myLogName,myRemoteMachine);
Console.WriteLine("Creating EventSource");
}
else
// Get the EventLog associated if the source exists.
myLogName = EventLog.LogNameFromSourceName("MyTestSource",myRemoteMachine);
EventLog myEventLog1 = new EventLog(myLogName,myRemoteMachine);
myEventLog1.Source = "MyTestSource";
// Write an entry into log.
myEventLog1.WriteEntry("This is for your information",
EventLogEntryType.SuccessAudit,100);
Console.WriteLine("An EventLog created on computer "+
myEventLog1.MachineName);
Console.Write( "Enter remote computer on which to create log : " );
myRemoteMachine = Console.ReadLine();
EventLog myEventLog2 = new EventLog();
myEventLog2.MachineName = myRemoteMachine;
myEventLog2.Source = "MyTestSource";
myEventLog2.Log = myEventLog1.LogDisplayName;
myEventLog2.WriteEntry("This is for your information");
Console.WriteLine("An EventLog created on computer "+
myEventLog2.MachineName);
[C++]
String* myRemoteMachine;
String* myLogName = S"MyLog";
Console::Write(S"Enter computer on which to create log : ");
myRemoteMachine = Console::ReadLine();
// Check if the source exists.
if (!EventLog::SourceExists(S"MyTestSource")) {
//Create source.
EventLog::CreateEventSource(S"MyTestSource", myLogName,myRemoteMachine);
Console::WriteLine(S"Creating EventSource");
} else
// Get the EventLog associated if the source exists.
myLogName = EventLog::LogNameFromSourceName(S"MyTestSource",myRemoteMachine);
EventLog* myEventLog1 = new EventLog(myLogName,myRemoteMachine);
myEventLog1->Source = S"MyTestSource";
// Write an entry into log.
myEventLog1->WriteEntry(S"This is for your information",
EventLogEntryType::SuccessAudit,100);
Console::WriteLine(S"An EventLog created on computer {0}", myEventLog1->MachineName);
Console::Write(S"Enter remote computer on which to create log : ");
myRemoteMachine = Console::ReadLine();
EventLog* myEventLog2 = new EventLog();
myEventLog2->MachineName = myRemoteMachine;
myEventLog2->Source = S"MyTestSource";
myEventLog2->Log = myEventLog1->LogDisplayName;
myEventLog2->WriteEntry(S"This is for your information");
Console::WriteLine(S"An EventLog created on computer {0}", myEventLog2->MachineName);
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- EventLogPermission (コンピュータ上のイベント ログ情報にアクセスするのに必要なアクセス許可)
- RegistryPermission (コンピュータ上のイベント ログ レジストリ情報にアクセスするのに必要なアクセス許可)
- SecurityPermission (完全信頼を指定して EventLog のメンバを呼び出すためのアクセス許可) PermissionState.Unrestricted (関連する列挙体)