Show / Hide Table of Contents

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
System.Object
ServiceExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: DevInstance.LogScope.Extensions
Assembly: DevInstance.LogScope.dll
Syntax
public static class ServiceExtensions

Methods

| Improve this Doc View Source

AddConsoleScopeLogging(IServiceCollection, LogLevel)

Creates and adds console manager to the service collection. Here is the example how use it in ConfigureServices method in ASP.NET Core app:

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

| Improve this Doc View Source

AddConsoleScopeLogging(IServiceCollection, LogLevel, DefaultFormattersOptions)

Creates and adds console manager to the service collection. Here is the example how use it in ConfigureServices method in ASP.NET Core app:

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

| Improve this Doc View Source

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. Here is the example how use it in ConfigureServices method in ASP.NET Core app:

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

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX