EventLog.MachineName プロパティ
アセンブリ: System (system.dll 内)

Dim instance As EventLog Dim value As String value = instance.MachineName instance.MachineName = value
/** @property */ public String get_MachineName () /** @property */ public void set_MachineName (String value)
イベント ログが存在するサーバーの名前。既定値はローカル コンピュータ (".") です。


イベント ログに書き込む場合は、Source をイベント ログ オブジェクトに関連付けて特定のログに接続する必要があります。ログを読み取るだけのときは Source プロパティを指定する必要はありません。指定できるのは、Log 名と MachineName (サーバー コンピュータ名) だけです。
![]() |
---|
ログに接続している場合は MachineName を指定する必要はありません。MachineName を指定しない場合は、ローカル コンピュータ (".") であると見なされます。 |
ソースは同時に 1 つのログだけに登録できます。EventLog のインスタンスに Source プロパティが設定されている場合は、先に Source の値を変更するかまたは DeleteEventSource を呼び出さない限り、その EventLog の MachineName プロパティを変更できません。MachineName プロパティを変更すると、EventLog はすべてのハンドルを閉じて、新しいコンピュータ上のログおよびソースに再び割り当てます。
MachineName 値を空の文字列にすることはできません。明示的に設定しなかった場合は、既定によりローカル コンピュータ (".") が設定されます。

指定したコンピュータ上のイベント ログ "NewEventLog" のエントリを読み取る例を次に示します。
Imports System Imports System.Diagnostics Imports Microsoft.VisualBasic Class MySample Public Shared Sub Main() Dim myNewLog As New EventLog() myNewLog.Log = "NewEventLog" myNewLog.MachineName = "MyServer" Dim entry As EventLogEntry For Each entry In myNewLog.Entries Console.WriteLine((ControlChars.Tab & "Entry: " & entry.Message)) Next entry End Sub ' Main End Class ' MySample
using System; using System.Diagnostics; class MySample{ public static void Main(){ EventLog myNewLog = new EventLog(); myNewLog.Log = "NewEventLog"; myNewLog.MachineName = "MyServer"; foreach(EventLogEntry entry in myNewLog.Entries){ Console.WriteLine("\tEntry: " + entry.Message); } } }
#using <System.dll> using namespace System; using namespace System::Diagnostics; int main() { EventLog^ myNewLog = gcnew EventLog; myNewLog->Log = "NewEventLog"; myNewLog->MachineName = "MyServer"; System::Collections::IEnumerator^ myEnum = myNewLog->Entries->GetEnumerator(); while ( myEnum->MoveNext() ) { EventLogEntry^ entry = safe_cast<EventLogEntry^>(myEnum->Current); Console::WriteLine( "\tEntry: {0}", entry->Message ); } }
import System.*; import System.Diagnostics.*; import System.Collections.*; class MySample { public static void main(String[] args) { EventLog myNewLog = new EventLog(); myNewLog.set_Log("NewEventLog"); myNewLog.set_MachineName("MyServer"); EventLogEntry entry; IEnumerator objEnum = myNewLog.get_Entries().GetEnumerator(); while (objEnum.MoveNext()) { entry = (EventLogEntry)objEnum.get_Current(); Console.WriteLine("\tEntry: " + entry.get_Message()); } } //main } //MySample


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からEventLog.MachineName プロパティを検索する場合は、下記のリンクをクリックしてください。

- EventLog.MachineName プロパティのページへのリンク