Class SerilogExtensions
- Namespace
- Microsoft.Extensions.Hosting
- Assembly
- Stratara.ServiceDefaults.dll
Serilog wiring used by every Stratara host. Configures structured logging with destructuring attributes,
async console sink, OTLP sink (when OTEL_EXPORTER_OTLP_ENDPOINT is set), and dev-mode log-file
cleanup at {Path.GetTempPath()}/stratara-logs/{service-name}.log.
public static class SerilogExtensions
- Inheritance
-
SerilogExtensions
- Inherited Members
Methods
ConfigureSerilog(IHostApplicationBuilder)
Registers Serilog as the host's logging provider with Stratara defaults (destructuring attributes, async
console sink, OTLP sink when configured). Reads additional configuration from appsettings.json
(Serilog section) and respects OTEL_EXPORTER_OTLP_ENDPOINT / OTEL_EXPORTER_OTLP_PROTOCOL
/ OTEL_SERVICE_NAME environment variables.
public static IHostApplicationBuilder ConfigureSerilog(this IHostApplicationBuilder builder)
Parameters
builderIHostApplicationBuilderThe host application builder.
Returns
- IHostApplicationBuilder
The same builder for chaining.
Examples
Reads the Serilog configuration section on top of Stratara's defaults:
builder.ConfigureSerilog();
ConfigureSerilogBootstrapLogger(ILogger)
Installs a Serilog bootstrap logger as the global Serilog.Log.Logger, so messages emitted before ConfigureSerilog(IHostApplicationBuilder) runs (early host startup) still reach the console.
public static ILogger ConfigureSerilogBootstrapLogger(this ILogger logger)
Parameters
loggerILoggerExisting Serilog.ILogger instance (typically Serilog.Log.Logger).
Returns
- ILogger
The same logger for chaining.