QERP.Logger
1.0.2
dotnet add package QERP.Logger --version 1.0.2
NuGet\Install-Package QERP.Logger -Version 1.0.2
<PackageReference Include="QERP.Logger" Version="1.0.2" />
<PackageVersion Include="QERP.Logger" Version="1.0.2" />
<PackageReference Include="QERP.Logger" />
paket add QERP.Logger --version 1.0.2
#r "nuget: QERP.Logger, 1.0.2"
#:package QERP.Logger@1.0.2
#addin nuget:?package=QERP.Logger&version=1.0.2
#tool nuget:?package=QERP.Logger&version=1.0.2
Qerp.LoggingPkg
Standardized logging library for QERP microservices based on Serilog and OpenTelemetry. It provides a unified way to configure structured logging, HTTP request monitoring, and distributed tracing across the ecosystem.
Features
- Structured Logging: Automatic indexing of log properties for efficient searching in Grafana Loki.
- Observability: Built-in support for W3C Trace Context, automatically attaching
TraceIdandSpanIdto all log events. - Pluggable Sinks: Configure multiple destinations with a single bitwise flag:
- Console: Formatted human-readable output.
- File: Structured JSON logs with rolling retention.
- Loki: Direct push to Grafana Loki.
- HTTP Request Monitoring: Automatic logging of request path, method, client IP, and performance metrics.
- Noise Reduction: pre-configured filters to silence verbose framework logs.
Installation
Add the package via the project properties or CLI:
dotnet add package QERP.Logger
Quick Start
1. Register Logging in Host
In your Program.cs, use the extension methods to register the logging services:
using Qerp.LoggingPkg;
var builder = WebApplication.CreateBuilder(args);
// Register QERP Logging
builder.AddQerpLogging(options =>
{
options.ApplicationName = "MyMicroservice";
options.Environment = "Development";
options.SinkType = LogSinkType.Console | LogSinkType.Loki;
options.LokiUrl = "http://loki:3100";
});
var app = builder.Build();
// Enable HTTP Request Logging
app.UseQerpRequestLogging();
app.Run();
2. Using the Logger
Inject ILogger<T> into your services:
public class MyService(ILogger<MyService> logger)
{
public void DoWork()
{
// Use structured logging (message templates)
logger.LogInformation("Processing item {ItemId}", 123);
}
}
Best Practices
- Avoid String Interpolation: Always use message templates (e.g.,
logger.LogInformation("User {UserId} logged in", userId)) to preserve structured data for Loki. - Log Exceptions correctly: Pass the
Exceptionobject as the first parameter toLogErrorto ensure stack traces are captured. - Trace Context: The package automatically handles distributed tracing. No manual TraceId attachment is required.
Documentation
For more detailed information, see:
License & Proprietary Notice
PROPRIETARY SOFTWARE: This library is a proprietary asset of QFL. Unauthorized redistribution, modification, or use outside of QFL-authorized projects is strictly prohibited.
For detailed licensing terms, see LICENSE.
Metadata
- Authors: Jewel Hossain
- License: QFL Proprietary
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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 is compatible. 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. |
-
net10.0
- Serilog (>= 4.2.0)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
- Serilog.Sinks.Grafana.Loki (>= 8.3.2)
-
net8.0
- Serilog (>= 4.2.0)
- Serilog.AspNetCore (>= 8.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
- Serilog.Sinks.Grafana.Loki (>= 8.3.0)
-
net9.0
- Serilog (>= 4.2.0)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
- Serilog.Sinks.Grafana.Loki (>= 8.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.