System.Diagnostics.EventLog.MachineName Property

Gets or sets the name of the computer on which to read or write events.

Syntax

[System.ComponentModel.DefaultValue(".")]
[System.ComponentModel.ReadOnly(true)]
[System.ComponentModel.RecommendedAsConfigurable(true)]
[System.Diagnostics.MonitoringDescription("Name of the machine that this log get written to.")]
public string MachineName { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

If you write to an event log, you must associate a EventLog.Source with your event log object to connect it to a particular log. It is not necessary to specify the EventLog.Source property when only reading from a log. You can specify only the EventLog.Log name and EventLog.MachineName (server computer name).

Note:

You need not specify the EventLog.MachineName if you are connecting to a log. If you do not specify the EventLog.MachineName, the local computer (".") is assumed.

A source can only be registered to one log at a time. If the EventLog.Source property was set for an instance of System.Diagnostics.EventLog, you cannot change the EventLog.MachineName property for that System.Diagnostics.EventLog without changing the value of EventLog.Source or calling EventLog.DeleteEventSource(string) first. If you change the EventLog.MachineName property, the System.Diagnostics.EventLog closes all handles and reattaches to the log and source on the new computer.

The EventLog.MachineName value cannot be an empty string. If it is not explicitly set, it defaults to the local computer (".").

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0