https://github.com/unitycontainer/microsoft-logging
Adapter for Microsoft.Extensions.Logging
https://github.com/unitycontainer/microsoft-logging
Last synced: 12 months ago
JSON representation
Adapter for Microsoft.Extensions.Logging
- Host: GitHub
- URL: https://github.com/unitycontainer/microsoft-logging
- Owner: unitycontainer
- License: apache-2.0
- Created: 2018-01-11T21:42:30.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T15:44:15.000Z (about 3 years ago)
- Last Synced: 2024-10-07T05:43:58.675Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 56.6 KB
- Stars: 16
- Watchers: 5
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://ci.appveyor.com/project/IoC-Unity/microsoft-logging/branch/master)
[](https://codecov.io/gh/unitycontainer/microsoft-logging)
[](https://github.com/IoC-Unity/microsoft-logging/blob/master/LICENSE)
[](https://ci.appveyor.com/project/IoC-Unity/microsoft-logging/branch/master)
[](https://www.nuget.org/packages/Unity.Microsoft.Logging)
# Microsoft.Extensions.Logging
Unity extension to integrate with [Microsoft.Extensions.Logging](https://www.nuget.org/packages?q=Microsoft.Extensions.Logging).
## Getting Started
- Reference the [Unity.Microsoft.Logging](https://www.nuget.org/packages/Unity.Microsoft.Logging) package from NuGet.
```shell
Install-Package Unity.Microsoft.Logging
```
### Create and configure LoggerFactory
```C#
ILoggerFactory loggerFactory = new LoggerFactory();
loggerFactory.AddProvider(new ConsoleLoggerProvider((text, logLevel) => logLevel >= LogLevel.Debug, false));
```
### Get the container
```C#
var container = new UnityContainer();
```
### Register extension and pass it configured factory
```C#
container.AddExtension(new LoggingExtension(loggerFactory));
// Register few types
container.RegisterType();
var service = container.Resolve();
```
For more information see [this example](https://github.com/unitycontainer/examples/tree/master/src/Logging/Microsoft.Logging)
## Code of Conduct
This project has adopted the code of conduct defined by the [Contributor Covenant](https://www.contributor-covenant.org/) to clarify expected behavior in our community. For more information, see the [.NET Foundation Code of Conduct](https://www.dotnetfoundation.org/code-of-conduct)
## Contributing
See the [Contributing guide](https://github.com/unitycontainer/unity/blob/master/CONTRIBUTING.md) for more information.
## .NET Foundation
Unity Container is a [.NET Foundation](https://dotnetfoundation.org/projects/unitycontainer) project