- Notifications
You must be signed in to change notification settings - Fork0
Extension destination for TacitusLogger that sends logs to database using Entity Framework ORM.
License
khanlarmammadov/TacitusLogger.Destinations.EntityFramework
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Extension destination for TacitusLogger that sends logs to database using Entity Framework ORM.
Dependencies:
- NET Standard >= 2.0
- TacitusLogger >= 0.3.0
- Microsoft.EntityFrameworkCore >= 2.0.0
Attention:
TacitusLogger.Destinations.EntityFramework
is currently inAlpha phase. This means you should not use it in any production code.
The NuGetpackage:
PM>Install-Package TacitusLogger.Destinations.EntityFramework
Using builders:
varlogger=LoggerBuilder.Logger().ForAllLogs().EntityFramework().WithDbContext(dbContext).Add().BuildLogger();
Directly:
IDbContextProviderdbContextProvider=newDbContextProvider(dbContext);IDbEntityBuilderdbEntityBuilder=newLogDbModelEntityBuilder();EntityFrameworkDestinationentityFrameworkDestination=newEntityFrameworkDestination(dbContextProvider,dbEntityBuilder);Loggerlogger=newLogger();logger.AddLogDestinations(entityFrameworkDestination);
Using builders:
LogModelFunc<DbContext>dbContextFunction=(logModel)=>{if(logModel.HasTag("App1"))returndbContext1;elsereturndbContext2;};varlogger=LoggerBuilder.Logger().ForAllLogs().EntityFramework().WithDbContext(dbContextFunction).Add().BuildLogger();
Directly:
IDbContextProviderfactoryMethodDbContextProvider=newFactoryMethodDbContextProvider((logModel)=>{if(logModel.HasTag("App1"))returndbContext1;elsereturndbContext2;});IDbEntityBuilderdbEntityBuilder=newLogDbModelEntityBuilder();EntityFrameworkDestinationentityFrameworkDestination=newEntityFrameworkDestination(factoryMethodDbContextProvider,dbEntityBuilder);Loggerlogger=newLogger();logger.AddLogDestinations(entityFrameworkDestination);
Using builders:
IDbContextProvidercustomDbContextProvider=newMock<IDbContextProvider>().Object;varlogger=LoggerBuilder.Logger().ForAllLogs().EntityFramework().WithDbContext(customDbContextProvider).Add().BuildLogger();
Directly:
IDbContextProvidercustomDbContextProvider=newMock<IDbContextProvider>().Object;IDbEntityBuilderdbEntityBuilder=newLogDbModelEntityBuilder();EntityFrameworkDestinationentityFrameworkDestination=newEntityFrameworkDestination(customDbContextProvider,dbEntityBuilder);Loggerlogger=newLogger();logger.AddLogDestinations(entityFrameworkDestination);
Using builders:
JsonSerializerSettingsjsonSerializerSettings=newJsonSerializerSettings();varlogger=LoggerBuilder.Logger().ForAllLogs().EntityFramework().WithDbContext(dbContext).WithLogModelDbEntity(jsonSerializerSettings).Add().BuildLogger();
Using builders:
LogModelFunc<Object>dbEntityFactoryMethod=(logModel)=>{returnnewMyCustomDbEntity(){LogId=logModel.LogId,Context=logModel.Context,Description=logModel.Description,LogType=logModel.LogType,LogDate=logModel.LogDate};};varlogger=LoggerBuilder.Logger().ForAllLogs().EntityFramework().WithDbContext(dbContext).WithDbEntity(dbEntityFactoryMethod).Add().BuildLogger();
Directly:
IDbContextProviderdbContextProvider=newDbContextProvider(dbContext);IDbEntityBuilderfactoryMethodDbEntityBuilder=newFactoryMethodDbEntityBuilder((logModel)=>{returnnewMyCustomDbEntity(){LogId=logModel.LogId,Context=logModel.Context,Description=logModel.Description,LogType=logModel.LogType,LogDate=logModel.LogDate};});EntityFrameworkDestinationentityFrameworkDestination=newEntityFrameworkDestination(dbContextProvider,factoryMethodDbEntityBuilder);Loggerlogger=newLogger();logger.AddLogDestinations(entityFrameworkDestination);
Using builders:
IDbEntityBuildercustomDbEntityBuilder=newMock<IDbEntityBuilder>().Object;varlogger=LoggerBuilder.Logger().ForAllLogs().EntityFramework().WithDbContext(dbContext).WithDbEntity(customDbEntityBuilder).Add().BuildLogger();
Directly:
IDbContextProviderdbContextProvider=newDbContextProvider(dbContext);IDbEntityBuildercustomDbEntityBuilder=newMock<IDbEntityBuilder>().Object;EntityFrameworkDestinationentityFrameworkDestination=newEntityFrameworkDestination(dbContextProvider,customDbEntityBuilder);Loggerlogger=newLogger();logger.AddLogDestinations(entityFrameworkDestination);
TacitusLogger:
- TacitusLogger - A simple yet powerful .NET logging library.
Destinations:
- TacitusLogger.Destinations.MongoDb - Extension destination for TacitusLogger that sends logs to MongoDb database.
- TacitusLogger.Destinations.RabbitMq - Extension destination for TacitusLogger that sends logs to the RabbitMQ exchanges.
- TacitusLogger.Destinations.Email - Extension destination for TacitusLogger that sends logs as emails using SMTP protocol.
- TacitusLogger.Destinations.Trace - Extension destination for TacitusLogger that sends logs to System.Diagnostics.Trace listeners.
Dependency injection:
- TacitusLogger.DI.Ninject - Extension for Ninject dependency injection container that helps to configure and add TacitusLogger as a singleton.
- TacitusLogger.DI.Autofac - Extension for Autofac dependency injection container that helps to configure and add TacitusLogger as a singleton.
- TacitusLogger.DI.MicrosoftDI - Extension for Microsoft dependency injection container that helps to configure and add TacitusLogger as a singleton.
Log contributors:
- TacitusLogger.Contributors.ThreadInfo - Extension contributor for TacitusLogger that generates additional info related to the thread on which the logger method was called.
- TacitusLogger.Contributors.MachineInfo - Extension contributor for TacitusLogger that generates additional info related to the machine on which the log was produced.
About
Extension destination for TacitusLogger that sends logs to database using Entity Framework ORM.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.