Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

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

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages