MSHelper.Logging
1.0.0
dotnet add package MSHelper.Logging --version 1.0.0
NuGet\Install-Package MSHelper.Logging -Version 1.0.0
<PackageReference Include="MSHelper.Logging" Version="1.0.0" />
paket add MSHelper.Logging --version 1.0.0
#r "nuget: MSHelper.Logging, 1.0.0"
// Install MSHelper.Logging as a Cake Addin #addin nuget:?package=MSHelper.Logging&version=1.0.0 // Install MSHelper.Logging as a Cake Tool #tool nuget:?package=MSHelper.Logging&version=1.0.0
MSHelper.Logging : Centralized logging with Serilog and Seq.
⭐ Star us on GitHub � it motivates us a lot!
Overview
Adds the logging capability, by default uses Serilog for logging with 3 optional extensions (sinks):
--- Console
--- File
--- Seq
Installation
This document is for the latest MSHelper.Logging 1.0.0 release and later.
dotnet add package MSHelper.Logging
Dependencies
-- MSHelper
Usage
Extend Program.cs → CreateDefaultBuilder()
with UseLogging()
that will add the required services and configure ILogger
available in ASP.NET Core framework.
public static IWebHostBuilder GetWebHostBuilder(string[] args)
=> WebHost.CreateDefaultBuilder(args)
.ConfigureServices(services => services.AddMSHelper().Build())
.UseLogging();
Then, simply inject ILogger<T>
(being ASP.NET Core built-in abstraction) to write the logs.
public class SomeService
{
private readonly ILogger<SomeService> _logger;
public SomeService(ILogger<SomeService> logger)
{
_logger = logger;
}
public void Foo()
{
_logger.LogInformation("Foo");
}
}
Options
--- applicationName - sets the optional application name property used for log enrichment.
--- serviceId - sets the optional service id property used for log enrichment.
--- excludePaths - optional endpoints that should be excluded from logging (e.g. while performing the health checks by other services).
--- console.enabled - enables/disables console logger.
--- file.enabled - enables/disables file logger.
--- file.path - path to the file logs.
--- file.interval - how often should the new file with logs be created.
--- seq.enabled - enables/disables Seq logger.
--- seq.url - URL to Seq API.
--- seq.token - API key (if provided) used while sending logs to Seq.
appsettings.json
"logger": {
"level": "information",
"excludePaths": ["/", "/ping", "/metrics"],
"excludeProperties": [
"api_key",
"access_key",
"ApiKey",
"ApiSecret",
"ClientId",
"ClientSecret",
"ConnectionString",
"Password",
"Email",
"Login",
"Secret",
"Token"
],
"console": {
"enabled": true
},
"elk": {
"enabled": false,
"url": "http://localhost:9200"
},
"file": {
"enabled": true,
"path": "logs/logs.txt",
"interval": "day"
},
"seq": {
"enabled": true,
"url": "http://localhost:5341",
"apiKey": "secret"
},
"tags": {}
},
Important Note:
All the MSHelper packages are for self learning purposes inspired by Devmentors.io
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- Microsoft.Extensions.Logging (>= 6.0.0)
- MSHelper (>= 1.0.0)
- Serilog (>= 2.12.0)
- Serilog.AspNetCore (>= 6.0.1)
- Serilog.Extensions.Logging (>= 3.1.0)
- Serilog.Sinks.Console (>= 4.1.0)
- Serilog.Sinks.Elasticsearch (>= 8.4.1)
- Serilog.Sinks.File (>= 5.0.0)
- Serilog.Sinks.Grafana.Loki (>= 8.0.1)
- Serilog.Sinks.Seq (>= 5.2.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MSHelper.Logging:
Package | Downloads |
---|---|
MSHelper.Logging.CQRS
MSHelper.Logging.CQRS - Centralized logging for CQRS with Serilog and Seq. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 259 | 10/25/2022 |