PostSharp 6.9 / / Post­Sharp Documentation / API Reference / Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Asp­Net­Core Namespace / Asp­Net­Core­Logging Class / Asp­Net­Core­Logging Methods / Asp­Net­Core­Logging.​Initialize Method

AspNetCoreLogging.Initialize Method

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

Namespace:  PostSharp.Patterns.Diagnostics.Adapters.AspNetCore
Assembly:  PostSharp.Patterns.Diagnostics.Adapters.AspNetCore (in PostSharp.Patterns.Diagnostics.Adapters.AspNetCore.dll) Version: 6.9.11.0 (6.9.11.0)
Syntax
C#
public static IDisposable Initialize(
	ICorrelationProtocol correlationProtocol = null,
	Predicate<HttpRequest> filter = null,
	LogEventMetadata metadata = null
)

Parameters

correlationProtocol (Optional)
Type: PostSharp.Patterns.Diagnostics.Correlation.ICorrelationProtocol
An optional implementation of ICorrelationProtocol to support distributed logging and interpret incoming request headers.
filter (Optional)
Type: System.Predicate<HttpRequest>
An optional predicate that determines which requests must be captured. If that parameter is omitted, the paths /lib, /css and /js will be ignored.
metadata (Optional)
Type: PostSharp.Patterns.Diagnostics.Custom.LogEventMetadata
An optional LogEventMetadata, which maps an HttpContext on a set of properties and an expression model. The default implementation is AspNetCoreRequestMetadata. You can derive this class if you want to add or remove properties. If you want to change the expression model, you have to derive the generic abstract AspNetCoreRequestMetadata<T>.

Return Value

Type: IDisposable

An opaque IDisposable that you can dispose to stop collecting logs from ASP.NET Core.

See Also