UnhandledExceptionLogger 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package UnhandledExceptionLogger --version 1.0.0
NuGet\Install-Package UnhandledExceptionLogger -Version 1.0.0
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="UnhandledExceptionLogger" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UnhandledExceptionLogger --version 1.0.0
#r "nuget: UnhandledExceptionLogger, 1.0.0"
#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.
// Install UnhandledExceptionLogger as a Cake Addin
#addin nuget:?package=UnhandledExceptionLogger&version=1.0.0

// Install UnhandledExceptionLogger as a Cake Tool
#tool nuget:?package=UnhandledExceptionLogger&version=1.0.0

ErrorLogger

A simplistic logger that hooks up to unhandled exceptions and logs them to a specified CSV file.

Installation

To install ErrorLogger, simply add the NuGet package to your project.

Usage

To start using ErrorLogger, initialize the logger in your main method:

var logger = new Logger();

You can also specify the log file path, the duration of the log history to keep, and the maximum size of the log file in kilobytes (KB) by using the following code:

var logger = new Logger(filePath, historyDuration, maxLogSize_KB);

Example

Here's an example of how you can use ErrorLogger in your project:

using ErrorLogger;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
            // initialize logger
            var logger = new Logger(
                filePath: "C:\\logs\\error.csv", 
                historyDuration: TimeSpan.FromDays(30.0), 
                maxLogSize_KB: 1024
                );
            // unhandled exception occurs, application crashes but exception gets logged
            throw new Exception("Test exception");
        }
    }
}

In the example above, the logger is initialized with the file path "C:\logs\error.csv", a history duration of 30 days, and a maximum log size of 1024 KB. The log file is roll over, old entries older than the specified duration are deleted. The same is true for the logfile size.

If no parameters are specified, the logger loggs to the application directory into a file errors.log with infinite size.

sample output

Date and Time Exception Type Description Location
2/26/2023 21:57 DataMisalignedException data is incorrect! at Program.<Main>$(String[] args) in C:\Users\julia\OneDrive\Projects\Libraries\ErrorLogger\TestingApplication\Program.cs:line 9
2/26/2023 21:58 Exception this is a test exeption! at Program.<Main>$(String[] args) in C:\Users\julia\OneDrive\Projects\Libraries\ErrorLogger\TestingApplication\Program.cs:line 9
2/26/2023 21:58 DataMisalignedException the data is misaligned! at Program.<Main>$(String[] args) in C:\Users\julia\OneDrive\Projects\Libraries\ErrorLogger\TestingApplication\Program.cs:line 9

License

ErrorLogger is released under the MIT-MODERN-VARIANT license.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 88 3/29/2024
1.1.1 168 7/26/2023
1.1.0 144 7/12/2023
1.0.1 183 2/26/2023
1.0.0 171 2/26/2023

capability to create a rolling log file in csv format. Will hook onto the unhandledException event handler