User Tools

Site Tools


Sidebar

Nebol Software Projects:

.NET Class Libraries

Contact info:

johan@nebol.se

nebollogger.entityframework

This is an old revision of the document!


NebolLogger.EntityFramework

The NebolLogger.EntityFramework library adds a Database destination to NebolLogger.

It creates and uses a couple of tables:

LogMachine - stores details on the machine that logs the entry (name, IP etc) LogApplication - stores details on the application that logs the entry (name etc) LogComponent - stores details on the component that logs the entry (source file, line etc) LogEntry - the actual log entry

.NET Core 3.0/3.1

static void SetupLogging()
{
	var optionsBuilder = new DbContextOptionsBuilder<NebolLoggerDbContext>();
	optionsBuilder.UseSqlServer(@"server=mssql.local;user id=sa;password=!Q2w#E4rqq;database=mixer_logg");

	using (var db = new NebolLoggerDbContext(optionsBuilder.Options))
		db.Database.Migrate();
	//db.Database.EnsureCreated();

	Destination_Database db_dest = new Destination_Database(optionsBuilder.Options);
	db_dest.Filters.Add(new Filter_Level(LogType.information));

	Logger.Instance.Destinations.Add(db_dest);
}
nebollogger.entityframework.1627908387.txt.gz · Last modified: 2021/08/02 14:46 by nebol