Open sandboxFocus

Class MicrosoftLoggingBackend

Logging backend for Microsoft.Extensions.Logging.

Inheritance
MicrosoftLoggingBackend
Implements
Namespace: PostSharp.Patterns.Diagnostics.Backends.Microsoft
Assembly: PostSharp.Patterns.Diagnostics.Backends.Microsoft.dll
Syntax
public class MicrosoftLoggingBackend : TextLoggingBackend, IDisposable
Remarks

To use this backend, create an instance with the ILoggerFactory of the application, for example the one of the ASP.NET Core host, and assign it to DefaultBackend before any logged code runs. Make sure the minimum level of the logging providers lets through the records you want to see.

To also route the events that your code logs directly with ILogger through PostSharp Logging, create this backend with a separate ILoggerFactory built from the output providers, and register MicrosoftLoggingCollectingLoggerProvider instead of those providers in the application.

Constructors

Name Description
MicrosoftLoggingBackend(ILoggerFactory)

Initializes a new instance of the MicrosoftLoggingBackend class with the given ILoggerFactory.

Properties

Name Description
Options

Gets the backend options.

Methods

Name Description
CreateRecordBuilder()

Creates a new LogRecordBuilder.

CreateTypeSource(LoggingNamespaceSource, Type)

Creates a LoggingTypeSource for the given role and type.

CreateTypeSourceBySourceName(LoggingNamespaceSource, string)

Creates a LoggingTypeSource for the given role and logger name.

GetLogger(string)

Gets an ILogger for the given category name.

GetTextBackendOptions()

Gets the options.

See Also