yourLogger.Exceptions.Core 0.0.14

There is a newer version of this package available.
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
                    
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="yourLogger.Exceptions.Core" Version="0.0.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="yourLogger.Exceptions.Core" Version="0.0.14" />
                    
Directory.Packages.props
<PackageReference Include="yourLogger.Exceptions.Core" />
                    
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 yourLogger.Exceptions.Core --version 0.0.14
                    
#r "nuget: yourLogger.Exceptions.Core, 0.0.14"
                    
#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 yourLogger.Exceptions.Core@0.0.14
                    
#: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=yourLogger.Exceptions.Core&version=0.0.14
                    
Install as a Cake Addin
#tool nuget:?package=yourLogger.Exceptions.Core&version=0.0.14
                    
Install as a Cake Tool

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

  1. Configure your DB (or not, if you want to log it somewhere else)
var dbOptions = new DbContextOptionsBuilder()
            .UseSqlServer(
                Configuration.GetConnectionString("ErrorDatabase"))
            .Options;
  1. Initiate the Builder
var loggerBuilder = new LoggerBuilder()
            .WithConsoleLevel(LogType.Trace)
            .WithExceptionTextProvider(ExceptionTextProviders.Default);
  1. 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);
  1. Add it to service collection
services.AddSingleton<ILogWriter>(logger.Writer);
services.AddSingleton<ILogReader>(logger.Reader);
  1. Start Logging Logging is simple, for Warn and Error 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
0.0.21 1,345 2/10/2022
0.0.20 1,286 2/10/2022
0.0.16 3,017 2/10/2022
0.0.15 1,622 2/8/2022
0.0.14 1,300 12/2/2021

Initial ugly release,