UnhandledExceptionLogger 1.0.1
See the version list below for details.
dotnet add package UnhandledExceptionLogger --version 1.0.1
NuGet\Install-Package UnhandledExceptionLogger -Version 1.0.1
<PackageReference Include="UnhandledExceptionLogger" Version="1.0.1" />
paket add UnhandledExceptionLogger --version 1.0.1
#r "nuget: UnhandledExceptionLogger, 1.0.1"
// Install UnhandledExceptionLogger as a Cake Addin #addin nuget:?package=UnhandledExceptionLogger&version=1.0.1 // Install UnhandledExceptionLogger as a Cake Tool #tool nuget:?package=UnhandledExceptionLogger&version=1.0.1
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 | Versions 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. |
-
net6.0
- QuickCsv.Net (>= 1.0.1)
-
net7.0
- QuickCsv.Net (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
updated github link