Open sandboxFocus

Class AspNetCoreLogging

Instruments the ASP.NET Core stack to define new logging activities (and possibly transactions) for incoming HTTP requests. This implementation is based on DiagnosticListener and will capture all incoming requests.

Inheritance
AspNetCoreLogging
Namespace: PostSharp.Patterns.Diagnostics.Adapters.AspNetCore
Assembly: PostSharp.Patterns.Diagnostics.Adapters.AspNetCore.dll
Syntax
public sealed class AspNetCoreLogging
Remarks

Call Initialize(ICorrelationProtocol, Predicate<HttpRequest>, LogEventMetadata) once when the application starts, and dispose of the object it returns to stop the instrumentation.

For distributed logging, pass an ICorrelationProtocol such as LegacyHttpCorrelationProtocol, and use the same protocol in the instrumentation of the clients. Accept correlation headers from trusted callers only, for example by passing a predicate to the constructor of LegacyHttpCorrelationProtocol.

Each captured request can open a logging transaction. A transaction policy of type AspNetCoreRequest in the logging configuration file can set the verbosity of selected requests, and its expressions see the request as an AspNetCoreRequestExpressionModel.

Constructors

Name Description
AspNetCoreLogging()

Methods

Name Description
Initialize(ICorrelationProtocol, Predicate<HttpRequest>, LogEventMetadata)

Instruments the ASP.NET Core stack to define new logging activities (and possibly transactions) for incoming HTTP requests.

See Also