jattac.libs.logger
1.0.0-beta01
See the version list below for details.
dotnet add package jattac.libs.logger --version 1.0.0-beta01
NuGet\Install-Package jattac.libs.logger -Version 1.0.0-beta01
<PackageReference Include="jattac.libs.logger" Version="1.0.0-beta01" />
paket add jattac.libs.logger --version 1.0.0-beta01
#r "nuget: jattac.libs.logger, 1.0.0-beta01"
// Install jattac.libs.logger as a Cake Addin #addin nuget:?package=jattac.libs.logger&version=1.0.0-beta01&prerelease // Install jattac.libs.logger as a Cake Tool #tool nuget:?package=jattac.libs.logger&version=1.0.0-beta01&prerelease
Jattac Logging Library
This basic yet extensible library build primarily to log exceptions.
Overview
It comes with two inbuilt log targets
- Console Logger Logs to the console.
- Disk Logger Logs to disk, and automatically deletes any files older than 30 days.
Usage
Simplest way to to create a global static instance program's startup. The constructor expects a HashSet of all the log targets that events shall be written.
public partial class Program
{
public static ErrorLogger ErrorLogger = new ErrorLogger(new HashSet<IErrorLogTarget>
{
new ConsoleErrorTarget(),
new DiskErrorLogTarget()
});
}
After setup, you may now use the logger in your code. E.g.
public void MyMethod()
{
try
{
// Error prone code
}
catch(Exception e)
{
ErrorLogger.Log(e, "Error occured when running the error prone section of the method");
}
}
Extending The Library
If you wish to log to additional targets, then simply create a class that implements the interface
public interface IErrorLogTarget
{
Task LogAsync(RichException richException);
}
Which only requires single async method that receives a single argument with the exception information.
After creating your class then, you can include it in the log targets during instantiation of the ErrorLogger
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 was computed. 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
- 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 |
---|---|---|
1.1.0-beta05 | 94 | 3/11/2024 |
1.1.0-beta04 | 202 | 2/1/2024 |
1.1.0-beta03 | 100 | 1/26/2024 |
1.1.0-beta02 | 90 | 1/25/2024 |
1.1.0-beta01 | 96 | 1/25/2024 |
1.0.0 | 238 | 12/21/2023 |
1.0.0-beta05 | 126 | 8/30/2023 |
1.0.0-beta04 | 132 | 6/17/2023 |
1.0.0-beta03 | 117 | 6/11/2023 |
1.0.0-beta02 | 110 | 6/11/2023 |
1.0.0-beta01 | 114 | 6/10/2023 |