Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

EventLog.LogDisplayName Property


Gets the event log's friendly name.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

public string LogDisplayName { get; }

Property Value

Type: System.String

A name that represents the event log in the system's event viewer.

Exception Condition

The specified Log does not exist in the registry for this computer.


In Windows Vista and later, users do not have permission to access the security log. If you are running Windows Vista or later as a user, you will get a SecurityException when you attempt to access the display name for an event in the security log.

In Windows Vista and later, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses the security log, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator.

The following example enumerates the event logs defined on the local computer and displays the LogDisplayName for each event log.

static void DisplayEventLogProperties()
    // Iterate through the current set of event log files,
    // displaying the property settings for each file.

    EventLog[] eventLogs = EventLog.GetEventLogs();
    foreach (EventLog e in eventLogs)
        Int64 sizeKB = 0;

        Console.WriteLine("{0}:", e.LogDisplayName);
        Console.WriteLine("  Log name = \t\t {0}", e.Log); 

        Console.WriteLine("  Number of event log entries = {0}", e.Entries.Count.ToString());

        // Determine if there is an event log file for this event log.
        RegistryKey regEventLog = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Services\\EventLog\\" + e.Log);
        if (regEventLog != null)
            Object temp = regEventLog.GetValue("File");
            if (temp != null)
                Console.WriteLine("  Log file path = \t {0}", temp.ToString());
                FileInfo file = new FileInfo(temp.ToString());

                // Get the current size of the event log file.
                if (file.Exists)
                    sizeKB = file.Length / 1024;
                    if ((file.Length % 1024) != 0)
                    Console.WriteLine("  Current size = \t {0} kilobytes", sizeKB.ToString());
                Console.WriteLine("  Log file path = \t <not set>");

        // Display the maximum size and overflow settings.

        sizeKB = e.MaximumKilobytes;
        Console.WriteLine("  Maximum size = \t {0} kilobytes", sizeKB.ToString());
        Console.WriteLine("  Overflow setting = \t {0}", e.OverflowAction.ToString());

        switch (e.OverflowAction)
            case OverflowAction.OverwriteOlder:
                Console.WriteLine("\t Entries are retained a minimum of {0} days.", 
            case OverflowAction.DoNotOverwrite:
                Console.WriteLine("\t Older entries are not overwritten.");
            case OverflowAction.OverwriteAsNeeded:
                Console.WriteLine("\t If number of entries equals max size limit, a new event log entry overwrites the oldest entry.");


for administering event log information on the computer. Associated enumeration: EventLogPermissionAccess.Administer


for the ability to read the specified registry key. Associated enumeration: RegistryPermissionAccess.Read


for the ability to access the specified registry key if it is a remote key. Associated enumeration: SecurityPermissionFlag.UnmanagedCode

.NET Framework
Available since 1.1
Return to top
© 2016 Microsoft