The NebolLogger.EntityFramework library adds a Database destination to NebolLogger.
See the nuget page at https://nuget.nebol.se for version history etc.
It creates and uses a couple of tables:
Create the empty database.
EF Migrations do not work (not yet in any case) so you need to create the schema contents either by running the script that is added to your project when installing the package (in the Database Scripts folder) or by calling Database.EnsureCreated() in your startup code.
If there are other tables in your database than the NebolLogger tables, the Database.EnsureCreated() call will fail as it requires an empty table on first call. In that scenario you should use the script.
Install-Package Microsoft.EntityFrameworkCore.SqlServer
using Microsoft.EntityFrameworkCore; using NebolLogger; using NebolLogger.Destinations.Database; using NebolLogger.EntityFramework; using NebolLogger.Filters;
static void SetupLogging() { var optionsBuilder = new DbContextOptionsBuilder<NebolLoggerDbContext>(); optionsBuilder.UseSqlServer(connection_string); using (var db = new NebolLoggerDbContext(optionsBuilder.Options)) db.Database.EnsureCreated(); Destination_Database db_dest = new Destination_Database(optionsBuilder.Options); db_dest.Filters.Add(new Filter_Level(LogType.information)); // skip trace messages Logger.Instance.Destinations.Add(db_dest); }
Create the empty database.
EF Migrations do not work (not yet in any case) so you need to create the schema contents by running the script that is added to your project when installing the package (in the Database Scripts folder)
Install-Package Microsoft.EntityFramework
using NebolLogger; using NebolLogger.Destinations.Database; using NebolLogger.EntityFramework; using NebolLogger.Filters;
static void SetupLogging() { Destination_Database db_dest = new Destination_Database(connection_string); db_dest.Filters.Add(new Filter_Level(LogType.information)); // skip trace messages Logger.Instance.Destinations.Add(db_dest); }
To prepare database, run in Package Manager:
update-database -ConfigurationTypeName NebolLogger.EntityFramework.NebolLoggerDbContextConfiguration -Verbose
or if you're using MySQL:
update-database -ConfigurationTypeName NebolLogger.EntityFramework.NebolLoggerDbContextConfiguration_MySQL -Verbose