RA.Utilities.Logging.Core
Version 10.1.2
Maintenance release — no API, behavior, or dependency changes.
Version 10.1.1
RequestIdEnricher is consolidated to a single TraceId property, LoggingExtensions is split into one class per extended type, and all extension classes are refactored to C# 14 extension members. Extension method names, signatures, and the namespace are unchanged.
⚠️ Breaking Changes
RequestIdEnrichernow adds a singleTraceIdproperty: the enricher no longer emits a separate request-id property (previously stored under the dashed namex-request-id), and it now writesTraceIdunconditionally. The value is resolved from thex-request-idheader first, thenHttpContext.TraceIdentifier, thenActivity.Current— so for requests that send the header,TraceIdnow holds the header value instead ofTraceIdentifier, and events outside a request carryTraceId: nullinstead of omitting the property. Migration: queryTraceIdinstead of the old request-id property, and exclude null values when grouping by trace id.
// v10.1.0
{ "x-request-id": "abc-123", "TraceId": "0HN7G3F2QK1L0:00000001" }
// v10.1.1
{ "TraceId": "abc-123" }
LoggingExtensionssplit intoWebApplicationBuilderExtensionsandLoggerEnrichmentConfigurationExtensions:AddLoggingWithConfiguration()(extension onWebApplicationBuilder) now lives inWebApplicationBuilderExtensions;WithRequestIdEnricher()(extension onLoggerEnrichmentConfiguration) lives inLoggerEnrichmentConfigurationExtensions. Both remain in theRA.Utilities.Logging.Core.Extensionsnamespace. Call sites need no changes — extension methods resolve by receiver type — but code that references theLoggingExtensionsclass name directly (typeof(...), unit-test assertions, reflection) must be updated. Migration: see the migration guide.
- var t = typeof(LoggingExtensions);
+ var b = typeof(WebApplicationBuilderExtensions); // AddLoggingWithConfiguration()
+ var e = typeof(LoggerEnrichmentConfigurationExtensions); // WithRequestIdEnricher()
+ var a = typeof(ActivityExtensions); // GetActivityId()
📝 Improvements
- C# 14 extension members:
WebApplicationBuilderExtensions,LoggerEnrichmentConfigurationExtensions, andActivityExtensionsnow declare their members insideextension(...)blocks onWebApplicationBuilder,LoggerEnrichmentConfiguration, andActivity. The generated extension methods keep identical names and signatures, so the refactor is source-compatible for all callers. - One class per extended type: the split mirrors the convention used across the RA.Utilities packages (
ServiceCollectionExtensions/ApplicationBuilderExtensions/ …), so each class has a single, obvious responsibility. GetActivityId()receiver is non-nullable: the C# 14 receiver is declared asActivity; call it with?.(Activity.Current?.GetActivityId()) to stay warning-free.- Documentation: the Logging.Core API reference is split into one page per extension class (
WebApplicationBuilderExtensions,LoggerEnrichmentConfigurationExtensions,ActivityExtensions), and a migration guide documents the newTraceId-only correlation model.
Version 10.0.2
Correlation moves from the log templates to the logging scope: BaseHttpLogTemplate no longer carries RequestId / TraceIdentifier, and request correlation is provided by the X-Request-Id log scope instead.
⚠️ Breaking Changes
RequestIdandTraceIdentifierremoved fromBaseHttpLogTemplate: the properties no longer exist onBaseHttpLogTemplate(and therefore not onHttpRequestLogTemplate/HttpResponseLogTemplateeither). Code that sets or reads these properties will not compile. Migration: carry the correlation ID in a log scope — sinks like the SerilogRequestIdEnricher(RA.Utilities.Logging.Core) pick upLoggingConstants.XRequestIdfrom the scope automatically.
- var log = new HttpRequestLogTemplate { RequestId = requestId, TraceIdentifier = traceId, ... };
+ using (logger.BeginScope(new Dictionary<string, object> { [LoggingConstants.XRequestId] = requestId }))
+ {
+ logger.LogInformation("HTTP Request: {@RequestLog}", log);
+ }
📝 Improvements
BaseHttpLogTemplatenow only containsPath,RequestedOn, andRemoteAddress;ToString()still returns the JSON-serialized representation.
public abstract class BaseHttpLogTemplate
{
- public string? RequestId { get; set; }
- public string? TraceIdentifier { get; set; }
public string? Path { get; set; }
public DateTime RequestedOn { get; set; } = DateTime.UtcNow;
public string? RemoteAddress { get; set; }
}
Version 10.1.0
This release makes HTTP-context registration explicit when request ID enrichment is enabled, avoiding an implicit ASP.NET Core service registration for applications that do not use it.
⚠️ Breaking Changes
-
IHttpContextAccessoris no longer registered automatically:AddLoggingWithConfigurationno longer registersIHttpContextAccessor. If you activateRequestIdEnricherthroughappsettings.jsonor.Enrich.WithRequestIdEnricher(), register it in your application:builder.Services.AddHttpContextAccessor();builder.AddLoggingWithConfiguration();
📝 Improvements
- Request ID enrichment remains opt-in: Activate
RequestIdEnricherthrough the SerilogEnrichconfiguration or the fluentWithRequestIdEnricherextension. - XML documentation clarified:
AddLoggingWithConfigurationnow documents the explicitIHttpContextAccessorregistration requirement for applications that enable request ID enrichment.
Version 10.0.1
This release fixes several bugs in the request ID enrichment pipeline, cleans up dead dependencies, and brings documentation in sync with the actual code.
⚠️ Breaking Changes
ActivityExtensions.GetActivityIdnow returnsstring?: The return type changed fromstringtostring?. When noActivitycontext is available, the method returnsnullinstead of a randomGuid. TheRequestIdEnricherskips adding theTraceIdproperty when the value is null — background and startup logs no longer receive unique random trace IDs per event. Migration: Update any code that assigns the result to a non-nullablestringvariable to usestring?instead.
📝 Improvements
RequestIdEnrichernow resolvesHttpContextlazily per event: Previously the enricher capturedHttpContextat construction time (alwaysnulloutside a request), making thex-request-idheader branch dead code. The enricher now stores theIHttpContextAccessorand resolvesHttpContexton eachEnrich()call, so request-scoped headers are correctly read.- Removed unused
Serilog.Settings.AppSettingsdependency: This legacy XML appSettings reader was not used by the code (configuration is read viaSerilog.Settings.Configuration, included transitively throughSerilog.AspNetCore). - Fixed broken XML doc crefs: Removed unresolvable cref references in
AddLoggingWithConfiguration's remarks and replaced them with plain-text descriptions. - Sample config cleaned up:
appsettings.serilog.jsonno longer contains developer-specific absolute paths or application names. - README updated: Replaced all references to the non-existent
AddRaSerilogmethod with the correctAddLoggingWithConfiguration. Rewrote "Key Features Configured by Default" to accurately reflect what the code configures vs. what is available viaappsettings.json.
Version 10.0.0
Updated the project version from 10.0.0-rc.2 to the stable release version 10.0.0 in preparation for a production release.
Version 10.0.0-rc.2
- Initial release of the core logging package.
- Provides
AddLoggingWithConfigurationextension method for opinionated Serilog configuration. - Includes request ID enrichment and exception details enrichment out of the box.
- Makes common Serilog sinks (Console, File, Async) and enrichers (Sensitive Data) available via
appsettings.jsonconfiguration.