Class ServiceExtensions
This class contains a collection of methods to support dependency injection (DI) software design pattern , which is a technique for achieving Inversion of Control (IoC) between classes and their dependencies.
Inheritance
Inherited Members
Namespace: DevInstance.LogScope.Extensions
Assembly: DevInstance.LogScope.dll
Syntax
public static class ServiceExtensions
Methods
| Improve this Doc View SourceAddConsoleScopeLogging(IServiceCollection, LogLevel)
Creates and adds console manager to the service collection.
public void ConfigureServices(IServiceCollection services)
{
...
services.AddConsoleScopeLogging(LogLevel.DEBUG);
...
}
Declaration
public static IServiceCollection AddConsoleScopeLogging(this IServiceCollection col, LogLevel level)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | col | collection of services |
LogLevel | level | logging level. See LogLevel |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | A reference to this instance after the operation has completed |
AddConsoleScopeLogging(IServiceCollection, LogLevel, DefaultFormattersOptions)
Creates and adds console manager to the service collection.
public void ConfigureServices(IServiceCollection services)
{
...
services.AddConsoleScopeLogging(LogLevel.DEBUG, new DefaultFormaterOptions { ShowTimestamp = true, ShowThreadNumber = true });
...
}
Declaration
public static IServiceCollection AddConsoleScopeLogging(this IServiceCollection col, LogLevel level, DefaultFormattersOptions options)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | col | collection of services |
LogLevel | level | logging level. See LogLevel |
DefaultFormattersOptions | options | Options for the default formatter. See DefaultFormattersOptions |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | A reference to this instance after the operation has completed |
AddScopeLogging(IServiceCollection, IScopeManager)
Adds already instantiated manager to the service collection. This method is useful
for adding manager with custom provider and formatter. DefaultScopeLogFactory
for more information how to create custom provider and formatter.
public void ConfigureServices(IServiceCollection services)
{
...
var manager = ScopeLogFactory.Create(LogLevel.DEBUG, myprovider, myformatter);
services.AddScopeLogging(manager);
...
}
Declaration
public static IServiceCollection AddScopeLogging(this IServiceCollection col, IScopeManager manager)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | col | collection of services |
IScopeManager | manager | instance of the log scope manager |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | A reference to this instance after the operation has completed |