LowCodeHub.Logging
0.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package LowCodeHub.Logging --version 0.0.1
NuGet\Install-Package LowCodeHub.Logging -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LowCodeHub.Logging" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LowCodeHub.Logging" Version="0.0.1" />
<PackageReference Include="LowCodeHub.Logging" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LowCodeHub.Logging --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LowCodeHub.Logging, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LowCodeHub.Logging@0.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LowCodeHub.Logging&version=0.0.1
#tool nuget:?package=LowCodeHub.Logging&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LowCodeHub.Logging
Production-oriented logging setup for ASP.NET Core using Serilog.
What this library gives you
- Structured logging (console + debug + optional file sink)
- HTTP request logging middleware
- Correlation ID enrichment
- Sensitive data masking support
- Optional Application Insights sink
- Safe request enrichment defaults (PII-conscious)
- Forwarded headers support for reverse proxies
- Startup validation for logging options
- Serilog SelfLog diagnostics for sink failures
Install
dotnet add package LowCodeHub.Logging
Quick start
using LowCodeHub.Logging.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.AddEnhancedSerilogLogging(
loggingSection: "LoggingOptions",
telemetrySection: "TelemetryOptions");
var app = builder.Build();
app.UseHttpContextEnricher();
app.MapGet("/", () => "ok");
app.Run();
Configuration (recommended baseline)
{
"LoggingOptions": {
"ServiceName": "orders-api",
"MinimumLogLevel": "Information",
"WriteToFile": true,
"FileLogging": {
"LogDirectory": "Logs",
"LogFileName": "app.log",
"RollingInterval": "Day",
"RetainedFileCountLimit": 14,
"SharedFile": true
},
"RequestEnrichment": {
"IncludeQueryString": false,
"IncludeAuthenticatedUser": false,
"IncludeUserRoles": false,
"IncludeUserAgent": true,
"IncludeReferer": false,
"AllowedQueryKeys": [ "page", "pageSize" ]
},
"ForwardedHeaders": {
"Enabled": true,
"ForwardLimit": 1,
"RequireHeaderSymmetry": true,
"KnownProxies": [ "10.0.0.10" ],
"KnownNetworks": [ "10.244.0.0/16" ]
},
"SelfLog": {
"Enabled": true,
"WriteToConsoleError": true,
"FilePath": "Logs/serilog-selflog.txt"
}
},
"TelemetryOptions": {
"Enabled": false,
"ConnectionString": ""
}
}
Best practices
- Set a real
ServiceNameper service. - Keep
IncludeQueryString=falseunless you truly need it. - If query logging is enabled, use
AllowedQueryKeysallowlist only. - Keep user identity fields disabled by default in public-facing APIs.
- Configure
KnownProxies/KnownNetworksin Kubernetes or behind ingress. - Enable
SelfLogin production to catch sink/serialization failures. - Use compact JSON logs in containerized environments.
- Keep file retention bounded to avoid disk exhaustion.
- Enable Application Insights only when you provide a valid connection string.
Application Insights
When TelemetryOptions.Enabled=true, this library registers AI telemetry and writes Serilog traces to the DI-managed TelemetryConfiguration.
Notes
- Health endpoint logs are excluded by default (
/healthpath filter). - Invalid configuration fails fast at startup.
UseHttpContextEnricher()should be registered early in the middleware pipeline.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.ApplicationInsights.AspNetCore (>= 3.0.0)
- Microsoft.Data.SqlClient (>= 6.1.4)
- Microsoft.EntityFrameworkCore (>= 10.0.3)
- Refit (>= 10.0.1)
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Enrichers.CorrelationId (>= 3.0.1)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Process (>= 3.0.0)
- Serilog.Enrichers.Sensitive (>= 2.1.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Formatting.Compact (>= 3.0.0)
- Serilog.Sinks.ApplicationInsights (>= 5.0.0)
- Serilog.Sinks.Async (>= 2.1.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.File (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.