QuickAssist.Logging
2.0.1
See the version list below for details.
dotnet add package QuickAssist.Logging --version 2.0.1
NuGet\Install-Package QuickAssist.Logging -Version 2.0.1
<PackageReference Include="QuickAssist.Logging" Version="2.0.1" />
<PackageVersion Include="QuickAssist.Logging" Version="2.0.1" />
<PackageReference Include="QuickAssist.Logging" />
paket add QuickAssist.Logging --version 2.0.1
#r "nuget: QuickAssist.Logging, 2.0.1"
#:package QuickAssist.Logging@2.0.1
#addin nuget:?package=QuickAssist.Logging&version=2.0.1
#tool nuget:?package=QuickAssist.Logging&version=2.0.1
QuickAssist.Logging
QuickAssist.Logging is a .NET 9 NuGet package for Serilog configuration, MediatR request logging, and ASP.NET Core exception handling. Its Serilog configuration writes rolling text files and can send events to Elasticsearch and Slack.
AddLoggingServies adds a request logging scope at the start of the ASP.NET Core middleware pipeline. Logs emitted within that HTTP request through the package's Serilog configuration share RequestId from HttpContext.TraceIdentifier, including logs outside MediatR handlers. LoggingBehavior also adds request type and available HTTP user fields while a MediatR request runs. It logs request and response types without serializing their bodies. Configure trusted forwarded headers in the consuming ASP.NET Core app before relying on RemoteIpAddressField. The default text file template prints RequestId and the active activity's distributed TraceId; other scope properties remain available to structured sinks. Startup logs, background jobs, and logs emitted before the request scope do not have an HTTP RequestId.
ConfigurationViewModel.FromConfiguration(IConfiguration) reads the existing ElasticConfiguration, SlackConfiguration, and FileConfiguration sections into one model. The logger utilities use that model internally; existing configuration keys remain unchanged.
Optional Elasticsearch sink
SeriLoggerUtility.Configure and StaticSeriLoggerUtility.CreateLoggerFactory add the Elasticsearch sink only when ElasticConfiguration:Uri has a value. TSeriLoggerUtility.Configure adds it only when ElasticConfiguration:Node1, Node2, and Node3 are all set; a partial node configuration fails with a clear error. Without these settings, file logging remains available.
Optional Slack sink
The logger utilities add the Slack error sink only when SlackConfiguration:WebHookUrl is set. Provide the webhook through protected configuration, such as the SlackConfiguration__WebHookUrl environment variable. Use environment-specific configuration values for Development, Staging, and Production. Without a webhook, file logging continues and no Slack sink is created. When enabled, the existing error/fatal filters remain in effect and Slack messages use an environment-specific display name, including Prod Critical Exception in Production.
File sink configuration
File logging is enabled by default with the existing logs_{projectName}/{projectName}-log.txt path, daily rolling, and seven retained files. Its text template appends RequestId="..." TraceId="..." to each line; unavailable values appear as empty quotes. RequestId identifies the HTTP request within the registered middleware pipeline; TraceId identifies the active distributed trace. The HTTP error response currently names its request identifier TraceId. Set FileConfiguration:Enabled to false to omit the file sink. When enabled, FileConfiguration:Path, FileConfiguration:RollingInterval, FileConfiguration:RetainedFileCountLimit, and FileConfiguration:OutputTemplate can override those defaults. A custom output template must include {RequestId:l} and {TraceId} to print the IDs. The path may contain {projectName}, which is replaced by the entry assembly name in lowercase with dots changed to hyphens. Invalid configured values fail with a configuration error.
Guidance for coding agents
The package contains two guidance files under docs/:
docs/AGENTS.mddescribes the package source and rules for maintaining it.docs/consumer-AGENTS.mdis a template for .NET applications that use the package.
NuGet does not make agents in consuming repositories automatically follow files inside a package. Copy the consumer template into the consuming repository as AGENTS.md, or add a short rule to that repository's existing AGENTS.md that points to the template and to this package's documentation. Review the template for the application's own logging configuration before using it.
The source copies of these files are in the QuickAssist.Logging repository. The packaged copies are provided for reference; they are not imported into an application automatically.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- EntityFramework (>= 6.5.1)
- MediatR (>= 12.0.0)
- Microsoft.EntityFrameworkCore (>= 9.0.20)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.20)
- Microsoft.Extensions.Logging (>= 9.0.20)
- Newtonsoft.Json (>= 13.0.1)
- Serilog (>= 4.2.0)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 2.2.0)
- Serilog.Extensions.Logging (>= 9.0.0)
- Serilog.Settings.Configuration (>= 9.0.0)
- Serilog.Sinks.Elasticsearch (>= 6.5.0)
- Serilog.Sinks.File (>= 6.0.0)
- Serilog.Sinks.Slack (>= 2.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.