a10b187708 | ||
---|---|---|
src | ||
tests | ||
.gitignore | ||
LICENSE | ||
README.md | ||
appveyor.yml | ||
package.props | ||
package.sln |
README.md
Microsoft.Extensions.Logging
Unity extension to integrate with Microsoft.Extensions.Logging.
Getting Started
- Reference the Unity.Microsoft.Logging package from NuGet.
Install-Package Unity.Microsoft.Logging
Create and configure LoggerFactory
ILoggerFactory loggerFactory = new LoggerFactory();
loggerFactory.AddProvider(new ConsoleLoggerProvider((text, logLevel) => logLevel >= LogLevel.Debug, false));
Get the container
var container = new UnityContainer();
Register extension and pass it configured factory
container.AddExtension(new LoggingExtension(loggerFactory));
// Register few types
container.RegisterType<IService, Service>();
var service = container.Resolve<IService>();
For more information see this example