Skip to content

net472_EventLogHelper.Interfaces_IEventLogWriter_GetLogForSource

dparvin edited this page Sep 10, 2025 · 1 revision

IEventLogWriter.GetLogForSource method

Retrieves the name of the event log that a given source is registered under on the specified machine.

public string GetLogForSource(string sourceName, string machineName)
parameter description
sourceName The name of the event source (e.g., "MyAppSource"). This must already exist on the target machine.
machineName The name of the machine to query. Use "." to indicate the local machine.

Return Value

The name of the event log (e.g., "Application", "System", or a custom log) that the specified source is registered to.

Exceptions

exception condition
ArgumentNullException Thrown when sourceName is null or empty.
ApplicationException Thrown when the log name could not be retrieved for the specified source on the given machine (e.g., due to registry corruption or insufficient access).

Remarks

This method wraps String) to provide testability and consistent error handling.

See Also

Clone this wiki locally