2018-01-14 02:52:35 +03:00
|
|
|
[![Build status](https://ci.appveyor.com/api/projects/status/r97hcdjf377ty6kq/branch/master?svg=true)](https://ci.appveyor.com/project/IoC-Unity/microsoft-logging/branch/master)
|
|
|
|
[![codecov](https://codecov.io/gh/unitycontainer/microsoft-logging/branch/master/graph/badge.svg)](https://codecov.io/gh/unitycontainer/microsoft-logging)
|
|
|
|
[![License](https://img.shields.io/badge/license-apache%202.0-60C060.svg)](https://github.com/IoC-Unity/microsoft-logging/blob/master/LICENSE)
|
|
|
|
[![Build status](https://ci.appveyor.com/api/projects/status/r97hcdjf377ty6kq/branch/master?svg=true)](https://ci.appveyor.com/project/IoC-Unity/microsoft-logging/branch/master)
|
|
|
|
[![NuGet](https://img.shields.io/nuget/v/Unity.Microsoft.Logging.svg)](https://www.nuget.org/packages/Unity.Microsoft.Logging)
|
|
|
|
|
|
|
|
|
2018-01-12 00:43:18 +03:00
|
|
|
# Microsoft.Extensions.Logging
|
2018-01-14 03:03:57 +03:00
|
|
|
Unity extension to integrate with [Microsoft.Extensions.Logging](https://www.nuget.org/packages?q=Microsoft.Extensions.Logging).
|
2018-01-14 03:01:08 +03:00
|
|
|
|
|
|
|
## Getting Started
|
2018-01-14 03:03:26 +03:00
|
|
|
- Reference the [Unity.Microsoft.Logging](https://www.nuget.org/packages/Unity.Microsoft.Logging) package from NuGet.
|
2018-01-14 03:01:08 +03:00
|
|
|
```
|
|
|
|
Install-Package Unity.Microsoft.Logging
|
|
|
|
```
|
|
|
|
|
2018-04-18 18:18:11 +03:00
|
|
|
### Create and configure LoggerFactory
|
2018-01-14 03:01:08 +03:00
|
|
|
```C#
|
2018-04-18 18:18:11 +03:00
|
|
|
ILoggerFactory loggerFactory = new LoggerFactory();
|
|
|
|
loggerFactory.AddProvider(new ConsoleLoggerProvider((text, logLevel) => logLevel >= LogLevel.Debug, false));
|
2018-01-14 03:01:08 +03:00
|
|
|
```
|
2018-04-18 18:18:11 +03:00
|
|
|
### Get the container
|
2018-01-14 03:01:08 +03:00
|
|
|
```C#
|
2018-04-18 18:18:11 +03:00
|
|
|
var container = new UnityContainer();
|
2018-01-14 03:01:08 +03:00
|
|
|
```
|
2018-04-18 18:18:11 +03:00
|
|
|
### Register extension and pass it configured factory
|
|
|
|
```C#
|
|
|
|
container.AddExtension(new LoggingExtension(loggerFactory));
|
|
|
|
|
|
|
|
// Register few types
|
|
|
|
container.RegisterType<IService, Service>();
|
|
|
|
|
|
|
|
var service = container.Resolve<IService>();
|
|
|
|
```
|
|
|
|
|
2018-04-18 18:20:16 +03:00
|
|
|
For more information see [this example](https://github.com/unitycontainer/examples/tree/master/src/Logging/Microsoft.Logging)
|
2018-01-12 22:56:58 +03:00
|
|
|
|
|
|
|
|