yourLogger.Exceptions.Core
0.0.14
See the version list below for details.
dotnet add package yourLogger.Exceptions.Core --version 0.0.14
NuGet\Install-Package yourLogger.Exceptions.Core -Version 0.0.14
<PackageReference Include="yourLogger.Exceptions.Core" Version="0.0.14" />
<PackageVersion Include="yourLogger.Exceptions.Core" Version="0.0.14" />
<PackageReference Include="yourLogger.Exceptions.Core" />
paket add yourLogger.Exceptions.Core --version 0.0.14
#r "nuget: yourLogger.Exceptions.Core, 0.0.14"
#:package yourLogger.Exceptions.Core@0.0.14
#addin nuget:?package=yourLogger.Exceptions.Core&version=0.0.14
#tool nuget:?package=yourLogger.Exceptions.Core&version=0.0.14
Icebear Logging Project
What is it
Icebear Exception Logging Library is an attempt to simplify the day to day workflow of a developer by creating a layer of abstraction that is extensible, with sensible defaults that anyone can start using within minutes.
The goal is that is all a developer needs to do, until they are ready to move on to an observability tool such as Datadog.
Why
As I was getting close to finishing up a project at my last job, I knew we did not have a good system for identifying exceptions. Sure we were logging it all, and it was available from the cloud provider, it would just be so much simpler if we could send user an Error number and look it in our storage.
Then I thought about how to do that, sure it wasn't difficult, it just takes a bit of time that you'd prefer that you wouldn't have to spend.
I decided it would be useful to create a minimum implementation of an Exception library, but keep it open such that additional functionalities can either be added easily through custom code, or additional nuget packages (which is still being worked on) And I think it is a bit more flexible than log4net, and easier to configure.
So now that I'm off work, this is the first project I wanted to work on.
What does it do?
This is a logging library, so obviously it logs. The Core project contains the base implementation on how to create the logger, and how the logger translates exceptions into a model that can be consumed There are several levels (pretty typical) of information
public enum LogType
{
Trace,
Info,
Warning,
Error,
Custom,
Custom1,
Custom2,
Custom3
}
How do I use it?
Really, there are four steps
- Configure your DB (or not, if you want to log it somewhere else)
var dbOptions = new DbContextOptionsBuilder()
.UseSqlServer(
Configuration.GetConnectionString("ErrorDatabase"))
.Options;
- Initiate the Builder
var loggerBuilder = new LoggerBuilder()
.WithConsoleLevel(LogType.Trace)
.WithExceptionTextProvider(ExceptionTextProviders.Default);
- Build the logger
var logger = loggerBuilder.Build(LogType.Info);
The above code builds the default logger which sends the log messages to Console, this isn't at all exciting
You likely would want to do something like the following to send the logs to DB.
var logger = loggerBuilder.WithWriter(
loggerBuilder.BuildInDb(LogContextProvider))
.Build(LogType.Info);
or for a bit more efficiency, a DB implementation that doesn't log every entry until it has enough
var logger = loggerBuilder.WithWriter(loggerBuilder.BuildRollingDb(
new Ef5Repository(LogContextProvider), 50))
.Build(LogType.Warning);
- Add it to service collection
services.AddSingleton<ILogWriter>(logger.Writer);
services.AddSingleton<ILogReader>(logger.Reader);
- Start Logging
Logging is simple, for
Warn
andError
type of logs, use the LogWarn or LogError Api
// Warn
await exceptionLogWriter.LogWarnAsync(new Exception("My bad"));
// Error
await exceptionLogWriter.LogErrorAsync(new Exception("My bad"));
For all custom events/logs, use the LogAsync method
await LogAsync<T>(LogType logType, string message, T detail);
TODO:
- Reader already works, working on a Razor page to make a pretty page
- Test with Dot net core 3.1 (works with .net 5 and .net 6, .Net 6 needs EF Core 6)
- A nosql implementation
What's in this Repo
In this Repo, there is one Abstraction (core) project, and one Implementation Project.
- Icebear.Exceptions.Core - Base implementation encompasses the base implementation for each type of logger
- The core project also includes an InMemory implementation as a sample
- Icebear.Exceptions.Db.Ef - Implementation that uses a DB as storage mechanism
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.7 is compatible. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.7
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 13.0.1)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
- System.Diagnostics.PerformanceCounter (>= 6.0.0)
-
.NETStandard 2.1
- Newtonsoft.Json (>= 13.0.1)
- System.Diagnostics.PerformanceCounter (>= 6.0.0)
-
net5.0
- Newtonsoft.Json (>= 13.0.1)
- System.Diagnostics.PerformanceCounter (>= 6.0.0)
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
- System.Diagnostics.PerformanceCounter (>= 6.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on yourLogger.Exceptions.Core:
Package | Downloads |
---|---|
yourLogger.Exceptions.Db.Ef
A relational DB implementation built on top of the IceBear.Exceptions.Core for storing logs in |
|
yourLogger.Exceptions.Mvc
Mvc Helper for the IceBear Exceptional Logging library . This is a Razor class library |
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial ugly release,