Skip to content

Extension for Microsoft dependency injection container that helps to configure and add TacitusLogger as a singleton.

License

Notifications You must be signed in to change notification settings

hanlarmammadov/TacitusLogger.DI.MicrosoftDI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TacitusLogger.DI.MicrosoftDI

Extension for Microsoft dependency injection container that helps to configure and add TacitusLogger as a singleton.

Dependencies:

  • NET Standard >= 1.3
  • Microsoft.Extensions.DependencyInjection >= 1.0.0
  • TacitusLogger >= 0.3.0

Attention: TacitusLogger.DI.MicrosoftDI is currently in Alpha phase. This means you should not use it in any production code.

Installation

The NuGet package:

PM> Install-Package TacitusLogger.DI.MicrosoftDI

Examples

Registering the Logger with DI Container

IServiceCollection serviceCollection = new ServiceCollection();
// Registering TacitusLogger with Microsoft DI as a singleton.
serviceCollection.TacitusLogger("logger1").ForAllLogs()
                                          .Console()
                                          .Add()
                                          .BuildLogger();

var serviceProvider = serviceCollection.BuildServiceProvider();

// Resolving the dependency
var logger = serviceProvider.GetService<ILogger>();

Or:

IServiceCollection serviceCollection = new ServiceCollection();
// Registering TacitusLogger with Microsoft DI as a singleton.
ILoggerBuilder loggerBuilder = serviceCollection.TacitusLogger("logger1"); 
loggerBuilder.ForAllLogs()
             .Console()
             .Add()
             .BuildLogger();

var serviceProvider = serviceCollection.BuildServiceProvider();

// Resolving the dependency
var logger = serviceProvider.GetService<ILogger>();

License

APACHE LICENSE 2.0

See also

TacitusLogger:

Destinations:

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.

Log contributors:

About

Extension for Microsoft dependency injection container that helps to configure and add TacitusLogger as a singleton.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages