Serilog.Extensions.Hosting Implements an ambient diagnostic context using . Consumers should use to set context properties. Construct a . A logger for binding properties in the context, or null to use . Start collecting properties to associate with the current diagnostic context. This will replace the active collector, if any. A collector that will receive properties added in the current diagnostic context. A container that receives properties added to a diagnostic context. Construct a . An object that will be disposed to signal completion/disposal of the collector. Add the property to the context. The property to add. Set the exception associated with the current diagnostic context. Passing an exception to the diagnostic context is useful when unhandled exceptions are handled before reaching Serilog's RequestLoggingMiddleware. One example is using https://www.nuget.org/packages/Hellang.Middleware.ProblemDetails to transform exceptions to ProblemDetails responses. If an unhandled exception reaches Serilog's RequestLoggingMiddleware, then the unhandled exception takes precedence.
If null is given, it clears any previously assigned exception.
The exception to log.
Complete the context and retrieve the properties added to it, if any. This will stop collection and remove the collector from the original execution context and any of its children. The collected properties, or null if no collection is active. True if properties could be collected. Complete the context and retrieve the properties and exception added to it, if any. This will stop collection and remove the collector from the original execution context and any of its children. The collected properties, or null if no collection is active. The collected exception, or null if none has been collected or if no collection is active. True if properties could be collected. Implements so that we can inject Serilog Logger. Initializes a new instance of the class. The Serilog logger; if not supplied, the static will be used. When true, dispose when the framework disposes the provider. If the logger is not specified but is true, the method will be called on the static class instead. Disposes the provider. Creates a new instance. The category name for messages produced by the logger. The . Adds an to the logging system. The . Collects diagnostic information for packaging into wide events. Set the specified property on the current diagnostic context. The property will be collected and attached to the event emitted at the completion of the context. The name of the property. Must be non-empty. The property value. If true, the value will be serialized as structured data if possible; if false, the object will be recorded as a scalar or simple array. Set the specified exception on the current diagnostic context. This method is useful when unhandled exceptions do not reach Serilog.AspNetCore.RequestLoggingMiddleware, such as when using Hellang.Middleware.ProblemDetails to transform exceptions to ProblemDetails responses. The exception to log. If null is given, it clears any previously assigned exception. Extends with methods for consuming host services. Configure the logger using components from the . If present, the logger will receive implementations/instances of , , , , , and . The `ReadFrom` configuration object. A from which services will be requested. A to support method chaining. Extends with Serilog configuration methods. Sets Serilog as the logging provider. The host builder to configure. The Serilog logger; if not supplied, the static will be used. When true, dispose when the framework disposes the provider. If the logger is not specified but is true, the method will be called on the static class instead. A registered in the Serilog pipeline using the WriteTo.Providers() configuration method, enabling other s to receive events. By default, only Serilog sinks will receive events. The host builder. Sets Serilog as the logging provider. A is supplied so that configuration and hosting information can be used. The logger will be shut down when application services are disposed. The host builder to configure. The delegate for configuring the that will be used to construct a . Indicates whether to preserve the value of . By default, Serilog does not write events to s registered through the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify true to write events to all providers. The host builder. Sets Serilog as the logging provider. A is supplied so that configuration and hosting information can be used. The logger will be shut down when application services are disposed. The host builder to configure. The delegate for configuring the that will be used to construct a . Indicates whether to preserve the value of . By default, Serilog does not write events to s registered through the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify true to write events to all providers. If the static is a bootstrap logger (see LoggerConfigurationExtensions.CreateBootstrapLogger()), and is not specified, the the bootstrap logger will be reconfigured through the supplied delegate, rather than being replaced entirely or ignored. The host builder. Extends with Serilog configuration methods. Sets Serilog as the logging provider. The service collection to use. The Serilog logger; if not supplied, the static will be used. When true, dispose when the framework disposes the provider. If the logger is not specified but is true, the method will be called on the static class instead. A registered in the Serilog pipeline using the WriteTo.Providers() configuration method, enabling other s to receive events. By default, only Serilog sinks will receive events. The service collection. Sets Serilog as the logging provider. The service collection to use. The delegate for configuring the that will be used to construct a . Indicates whether to preserve the value of . By default, Serilog does not write events to s registered through the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify true to write events to all providers. The service collection. Sets Serilog as the logging provider. The service collection to use. The delegate for configuring the that will be used to construct a . Indicates whether to preserve the value of . By default, Serilog does not write events to s registered through the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify true to write events to all providers. If the static is a bootstrap logger (see LoggerConfigurationExtensions.CreateBootstrapLogger()), and is not specified, the the bootstrap logger will be reconfigured through the supplied delegate, rather than being replaced entirely or ignored. The service collection.