LoggingHelperPackage-dev
11.5.1
dotnet add package LoggingHelperPackage-dev --version 11.5.1
NuGet\Install-Package LoggingHelperPackage-dev -Version 11.5.1
<PackageReference Include="LoggingHelperPackage-dev" Version="11.5.1" />
<PackageVersion Include="LoggingHelperPackage-dev" Version="11.5.1" />
<PackageReference Include="LoggingHelperPackage-dev" />
paket add LoggingHelperPackage-dev --version 11.5.1
#r "nuget: LoggingHelperPackage-dev, 11.5.1"
#:package LoggingHelperPackage-dev@11.5.1
#addin nuget:?package=LoggingHelperPackage-dev&version=11.5.1
#tool nuget:?package=LoggingHelperPackage-dev&version=11.5.1
Log Helper Library
- Logs all the controllers' actions inputs and results
Setup
- Ensure Serilog is installed in the application you want to log.
- Use the IServiceCollection extension method to register the logging middleware via
services.RegisterLogging();. - Configure the logging middleware through your appsettings.json file. The following is an example configuration:
{
"Applications": {
"Apps": {
"LoggingEnabled": true,
"appName": "<App Name>",
"collectionName": "<MongoDB Collection Name>",
"DatabaseName": "<MongoDB DB Name>",
"DatabaseConnection": "<MongoDB Connection String",
"Loki": {
"Enable": true,
"Url": "<Loki Connection String>",
"Labels": [
{
"Key": "app",
"Value": "<App Name>"
},
{
"Key": "environment",
"Value": "<Environment Name>"
},
{
"Key": "jobs",
"Value": "HangFire"
}
],
"UserName": <Username>,
"Password": <Password>
},
"MSSQL": {
"Enable": false,
"ConnectionString": "<Connection String>",
"TableName": "<Table Name>"
},
"OTLPConfig": {
"Enabled": true
}
}
},
}
Notes
- The middleware mainly logs request failure/completion, if you need to log DB queries to Aspire, ensure you've added
"Microsoft.EntityFrameworkCore.Database.Command": "Information"to your logging config. - MongoDB logging is enabled by default, if you want to disable it, set the
LoggingEnabledproperty to false in your appsettings.json file.
Old Documentation
<h1>Log Helper Library </h1> <p> This library is customized to log all the controllers' actions inputs and results</p> <h3> How to use</h3> <ol> <li>Install Serilog pckage in the application you want to log</li> <li>In program.cs, add the using statement : using LoggingHelperLibrary</li> <li>In program.cs, add the following code <p>var AppLogging = new Application() { AppName = "DigitalPlatformVacation", CollectionName = "DigitalPlatformVacation", DatabaseName = "ApplicationsLogs", DatabaseConnection = "mongodb://eva-mongodb:mZ3aja0u8ozMtwV1LvK9HEMLG0B12vmEcmcG4kmvE5Qjmzjbdtkz1yyoGEZxi5jbvbas2zzo6MQBfEqBDZRLlw==@eva-mongodb.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@eva-mongodb@" }; </br>Log.Logger = BuildLoggerObject.BuildLogger(AppLogging.DatabaseConnection, AppLogging.DatabaseName, AppLogging.CollectionName); </p> </li> <li>In program.cs,replace this line --> builder.Services.AddControllers(); by this--> builder.Services.AddControllers(x ⇒ x.Filters.Add<LogFilterAttribute>()); </li> <li>In program.cs, register the log middlewares before MapControllers Middleware --> RegisterLogsMiddlewares.LogsMiddlewareRegister(app);</li> <li>Add the folloing packages references in .csproj file</br> <PackageReference Include="Newtonsoft.Json" Version="13.0.2" /></br> <PackageReference Include="Serilog.AspNetCore" Version="6.1.0" /></br> <PackageReference Include="Serilog.Exceptions" Version="8.4.0" /></br> <PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" /></br> <PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" /></br> <PackageReference Include="Serilog.Sinks.MongoDB" Version="5.3.1" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.26.0" /></br> </li> </ol>
| 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 was computed. 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. |
-
net8.0
- OpenTelemetry (>= 1.9.0)
- OpenTelemetry.Exporter.Console (>= 1.9.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.9.0)
- OpenTelemetry.Extensions.Hosting (>= 1.9.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.9.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.0.0-beta.12)
- OpenTelemetry.Instrumentation.Http (>= 1.9.0)
- OpenTelemetry.Instrumentation.Process (>= 0.5.0-beta.4)
- OpenTelemetry.Instrumentation.Runtime (>= 1.9.0)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.9.0-beta.1)
- Serilog.AspNetCore (>= 8.0.1)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Hosting (>= 8.0.0)
- Serilog.Settings.Configuration (>= 8.0.2)
- Serilog.Sinks.Grafana.Loki (>= 8.3.1)
- Serilog.Sinks.MongoDB (>= 7.0.0)
- Serilog.Sinks.MSSqlServer (>= 8.1.0)
- Serilog.Sinks.OpenTelemetry (>= 4.2.0)
- Serilog.Sinks.Seq (>= 9.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.5.1 | 175 | 10/27/2025 |