EventLogHelper 2025.8.17.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package EventLogHelper --version 2025.8.17.2
                    
NuGet\Install-Package EventLogHelper -Version 2025.8.17.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EventLogHelper" Version="2025.8.17.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EventLogHelper" Version="2025.8.17.2" />
                    
Directory.Packages.props
<PackageReference Include="EventLogHelper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EventLogHelper --version 2025.8.17.2
                    
#r "nuget: EventLogHelper, 2025.8.17.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EventLogHelper@2025.8.17.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EventLogHelper&version=2025.8.17.2
                    
Install as a Cake Addin
#tool nuget:?package=EventLogHelper&version=2025.8.17.2
                    
Install as a Cake Tool

EventLogHelper Icon EventLogHelper

EventLogHelper is a lightweight .NET library designed to make logging to the Windows Event Log simple, safe, and flexible β€” without requiring repetitive boilerplate or administrative headaches.


πŸš€ Features

  • βœ… One-line logging to the Windows Event Log
  • βœ… Automatically creates event sources (with safe fallbacks)
  • βœ… Works in non-elevated environments
  • βœ… Configurable defaults via App.config, Web.config, or appsettings.json (automatically loaded at first use)
  • βœ… Gracefully handles permission issues and registry conflicts
  • βœ… Configurable logging severity (filter logs by importance)

πŸ’‘ Why Use EventLogHelper?

The built-in .NET System.Diagnostics.EventLog API requires:

  • Admin rights to create sources
  • Manually checking for source/log conflicts
  • Verbose, repeated code everywhere you want to log

EventLogHelper abstracts all that into a single method call, with smart defaults and self-healing behavior.


🧾 Example Usage

Basic logging with default source and log name:

SmartEventLogger.Log("Application started.")
SmartEventLogger.Log("A warning occurred.", EventLogEntryType.Warning)
SmartEventLogger.Log("An error occurred.", EventLogEntryType.Error)

Custom source and log name:


SmartEventLogger.MachineName = "."
SmartEventLogger.LogName = "MyCompanyLog"
SmartEventLogger.SourceName = "MyServiceSource"

SmartEventLogger.Log("Service initialized.",
                     EventLogEntryType.Information)

Or with a fluent interface using GetLog:


SmartEventLogger.GetLog("MyCompanyLog", "MyServiceSource").
    LogEntry("Service initialized.", EventLogEntryType.Information)

Advanced usage with full customization:


SmartEventLogger.Log(
    _machineName: ".",
    _logName: "CustomLog",
    sourceName: "CustomSource",
    message: "This is a custom log entry.",
    eventType: EventLogEntryType.Information,
    eventID: 1001,
    category: 0,
    rawData: Nothing,
    maxKilobytes: 1024 * 1024,    ' 1 GB
    retentionDays: 7,
    writeInitEntry: True,
    EntrySeverity: LoggingSeverity.Info)

You can also configure default values and plug in a custom writer for unit testing or specialized behavior.


βš™οΈ Configuration via App Settings

SmartEventLogger can initialize itself automatically using application configuration files:

  • .NET Framework – settings are read from <appSettings> in App.config or Web.config.
  • .NET Core / .NET 5+ – settings are read from appsettings.json.

If you don’t call InitializeConfiguration() explicitly, these settings will be loaded automatically the first time you use the logger.


πŸ”’ Security Notes

  • Creating new sources requires admin privileges.
  • In non-elevated environments, EventLogHelper will automatically fall back to an existing source (e.g., the log name or "Application").

πŸ“„ License

MIT License. See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows10.0.17763 is compatible.  net9.0-windows was computed.  net9.0-windows10.0.17763 is compatible.  net10.0-windows was computed. 
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.9.10.2 37 9/10/2025
2025.9.8.1 50 9/8/2025
2025.8.18.1 129 8/19/2025
2025.8.17.2 127 8/18/2025
2025.8.17.1 124 8/18/2025
2025.8.16.1 56 8/16/2025
2025.8.10.1 126 8/11/2025
2025.8.7.1 208 8/7/2025
2025.8.3.1 168 8/4/2025
2025.8.2.1 68 8/2/2025
2025.7.26.13 107 7/27/2025