yourLogger.Exceptions.Db.Ef
0.0.14
See the version list below for details.
dotnet add package yourLogger.Exceptions.Db.Ef --version 0.0.14
NuGet\Install-Package yourLogger.Exceptions.Db.Ef -Version 0.0.14
<PackageReference Include="yourLogger.Exceptions.Db.Ef" Version="0.0.14" />
<PackageVersion Include="yourLogger.Exceptions.Db.Ef" Version="0.0.14" />
<PackageReference Include="yourLogger.Exceptions.Db.Ef" />
paket add yourLogger.Exceptions.Db.Ef --version 0.0.14
#r "nuget: yourLogger.Exceptions.Db.Ef, 0.0.14"
#:package yourLogger.Exceptions.Db.Ef@0.0.14
#addin nuget:?package=yourLogger.Exceptions.Db.Ef&version=0.0.14
#tool nuget:?package=yourLogger.Exceptions.Db.Ef&version=0.0.14
yourLogger Exception EF Core Logger
This is the EF Core implementation of the yourLogger Logging Library
Why?
The intention of the library was to simplify something all developers have to implement many times over their career. Logging
Logging is a very common and important task. Therefore it should be super simple to implement.
For example, with lombok annotations. All you need to start logging is use the @Sfj4 annotation on the class.
For DotNet Core, it can be as simple as passing in ILogger to the constructor thanks to the magic of dependency injection.
But it only prints to console, and we need more than that. We need to store the logs and inspect them later.
When an exception occurs, it may even be helpful to present a page to the user with a reference number.
yourLogger is a library that looks to abstract it all away. The Ef Core Logger implementation is the Ef core implementation of that abstraction.
How do I use this?
Install the nuget package.
Instantiate the Builder using
c# DbContextOptionsBuilder
Make sure the appropriate EF Core package is installed
For example, the below snippet creates a Database Option using the "ErrorDatabase" Section in AppSettings.Json
var dbOptions = new DbContextOptionsBuilder()
.UseSqlServer(
Configuration.GetConnectionString("ErrorDatabase"))
.Options;
- Initiate a LogWriterBuilder to build the logger
var loggerBuilder = new LoggerBuilder()
.WithConsoleLevel(LogType.Warn);
- Pass in the DB writer to the log builder.
loggerBuilder = loggerBuilder.WithWriter(
loggerBuilder.BuildInDb(LogContextProvider));
- Build the Logger
var logger = loggerBuilder.Build(LogType.Info);
Alternatively, or more simply, we can combine steps 4 and 5 together
var logger = loggerBuilder.WithWriter(
loggerBuilder.BuildInDb(LogContextProvider))
.Build(LogType.Info);
- As the core package, use
c#logger.Writer
andc#logger.Reader
for all your logging needs.
Customization
This library provides two different implementations:
- Simple DB built with
BuildInDb
or This logger stores each log to the DB as they come in - Rolling DB built with
BuildWithRolling
The rolling DB implementation collects the logs in memory, and commits the entire batch to the database when there are more than >batchSize
number of entries in memory.
Changing Table Name
Although most of the EF Core implementation is internal to the nuget package, it is still possible to change the table name. Create a new Context, inherit LogDbContext, and have the LogContextProvider return your new Context. And you can change the default table settings via the OnConfiguring hook.
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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.EntityFrameworkCore.SqlServer (>= 5.0.11)
- yourLogger.Exceptions.Core (>= 0.0.14)
-
net5.0
- Microsoft.EntityFrameworkCore.SqlServer (>= 5.0.11)
- yourLogger.Exceptions.Core (>= 0.0.14)
-
net6.0
- Microsoft.EntityFrameworkCore (>= 6.0.0)
- Microsoft.EntityFrameworkCore.Abstractions (>= 6.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 5.0.11)
- yourLogger.Exceptions.Core (>= 0.0.14)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial Ugly release