<PackageReference Include="System.Diagnostics.EventLog" Version="5.0.0-preview.6.20305.6" />

EventLog

Provides interaction with Windows event logs.
public bool EnableRaisingEvents { get; set; }

Gets or sets a value indicating whether the EventLog receives EntryWritten event notifications.

Gets the contents of the event log.

public string Log { get; set; }

Gets or sets the name of the log to read from or write to.

public string LogDisplayName { get; }

Gets the event log's friendly name.

public string MachineName { get; set; }

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

public long MaximumKilobytes { get; set; }

Gets or sets the maximum event log size in kilobytes.

public int MinimumRetentionDays { get; }

Gets the number of days to retain entries in the event log.

Gets the configured behavior for storing new entries when the event log reaches its maximum log file size.

public string Source { get; set; }

Gets or sets the source name to register and use when writing to the event log.

Gets or sets the object used to marshal the event handler calls issued as a result of an EventLog entry written event.

Occurs when an entry is written to an event log on the local computer.

public EventLog()

Initializes a new instance of the EventLog class. Does not associate the instance with any log.

public EventLog(string logName)

Initializes a new instance of the EventLog class. Associates the instance with a log on the local computer.

public EventLog(string logName, string machineName)

Initializes a new instance of the EventLog class. Associates the instance with a log on the specified computer.

public EventLog(string logName, string machineName, string source)

Initializes a new instance of the EventLog class. Associates the instance with a log on the specified computer and creates or assigns the specified source to the EventLog.

public static void CreateEventSource(EventSourceCreationData sourceData)

Establishes a valid event source for writing localized event messages, using the specified configuration properties for the event source and the corresponding event log.

public static void CreateEventSource(string source, string logName)

Establishes the specified source name as a valid event source for writing entries to a log on the local computer. This method can also create a new custom log on the local computer.

public static void CreateEventSource(string source, string logName, string machineName)

Establishes the specified source name as a valid event source for writing entries to a log on the specified computer. This method can also be used to create a new custom log on the specified computer.

public static void Delete(string logName)

Removes an event log from the local computer.

public static void Delete(string logName, string machineName)

Removes an event log from the specified computer.

public static void DeleteEventSource(string source)

Removes the event source registration from the event log of the local computer.

public static void DeleteEventSource(string source, string machineName)

Removes the application's event source registration from the specified computer.

public static bool Exists(string logName)

Determines whether the log exists on the local computer.

public static bool Exists(string logName, string machineName)

Determines whether the log exists on the specified computer.

public static EventLog[] GetEventLogs()

Searches for all event logs on the local computer and creates an array of EventLog objects that contain the list.

public static EventLog[] GetEventLogs(string machineName)

Searches for all event logs on the given computer and creates an array of EventLog objects that contain the list.

public static string LogNameFromSourceName(string source, string machineName)

Gets the name of the log to which the specified source is registered.

public static bool SourceExists(string source)

Determines whether an event source is registered on the local computer.

public static bool SourceExists(string source, string machineName)

Determines whether an event source is registered on a specified computer.

public static void WriteEntry(string source, string message)

Writes an information type entry with the given message text to the event log, using the specified registered event source.

public static void WriteEntry(string source, string message, EventLogEntryType type)

Writes an error, warning, information, success audit, or failure audit entry with the given message text to the event log, using the specified registered event source.

public static void WriteEntry(string source, string message, EventLogEntryType type, int eventID)

Writes an entry with the given message text and application-defined event identifier to the event log, using the specified registered event source.

public static void WriteEntry(string source, string message, EventLogEntryType type, int eventID, short category)

Writes an entry with the given message text, application-defined event identifier, and application-defined category to the event log, using the specified registered event source. The category can be used by the Event Viewer to filter events in the log.

public static void WriteEntry(string source, string message, EventLogEntryType type, int eventID, short category, byte[] rawData)

Writes an entry with the given message text, application-defined event identifier, and application-defined category to the event log (using the specified registered event source) and appends binary data to the message.

public static void WriteEvent(string source, EventInstance instance, byte[] data, object[] values)

Writes an event log entry with the given event data, message replacement strings, and associated binary data, and using the specified registered event source.

public static void WriteEvent(string source, EventInstance instance, object[] values)

Writes an event log entry with the given event data and message replacement strings, using the specified registered event source.

public void BeginInit()

Begins the initialization of an EventLog used on a form or used by another component. The initialization occurs at runtime.

public void Clear()

Removes all entries from the event log.

public void Close()

Closes the event log and releases read and write handles.

public void EndInit()

Ends the initialization of an EventLog used on a form or by another component. The initialization occurs at runtime.

public void ModifyOverflowPolicy(OverflowAction action, int retentionDays)

Changes the configured behavior for writing new entries when the event log reaches its maximum file size.

public void RegisterDisplayName(string resourceFile, long resourceId)

Specifies the localized name of the event log, which is displayed in the server Event Viewer.

public void WriteEntry(string message)

Writes an information type entry, with the given message text, to the event log.

public void WriteEntry(string message, EventLogEntryType type)

Writes an error, warning, information, success audit, or failure audit entry with the given message text to the event log.

public void WriteEntry(string message, EventLogEntryType type, int eventID)

Writes an entry with the given message text and application-defined event identifier to the event log.

public void WriteEntry(string message, EventLogEntryType type, int eventID, short category)

Writes an entry with the given message text, application-defined event identifier, and application-defined category to the event log.

public void WriteEntry(string message, EventLogEntryType type, int eventID, short category, byte[] rawData)

Writes an entry with the given message text, application-defined event identifier, and application-defined category to the event log, and appends binary data to the message.

public void WriteEvent(EventInstance instance, byte[] data, object[] values)

Writes an event log entry with the given event data, message replacement strings, and associated binary data.

public void WriteEvent(EventInstance instance, object[] values)

Writes a localized entry to the event log.