An open API service indexing awesome lists of open source software.

https://github.com/intility/intility.logging

Logging packages supporting the starter templates
https://github.com/intility/intility.logging

dotnet

Last synced: 6 months ago
JSON representation

Logging packages supporting the starter templates

Awesome Lists containing this project

README

          




Intility.Logging

Logging enhancement for backend projects using aspnet or dotnet generic host
by providing common infrastructure and sensible defaults.

Focus on writing and designing business-logic
and less time worrying about operational concerns.



Release workflow


Build workflow



nuget


nuget


nuget


nuget

## ⚡️ Quick start

First of all this package is already included in the [Intility templates](https://github.com/Intility/templates), but can be installed separately. Installation is done with the `dotnet add package` command or via Visual Studio Package Manager.

```shell
# install common infrastructure
dotnet add package Intility.Logging.AspNetCore
```

To instrument the runtime with the new logging capabilities you will need to use an extension method on the `IHostBuilder` interface

```csharp
// Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseIntilityLogging((hostContext, logging) =>
{
// add default metadata on log events
logging.UseDefaultEnrichers();
})
//...
```

## ⚙️ Configuration

The base package inclues a Console sink with a format supporting structured logging. Use configuration section `Serilog` to configure the loglevel override and other supported settings. See [Serilog]() for more information.

```json
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"System": "Warning",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Properties": {
"Application": "MyApp"
}
}
}
```

## 🛰️ Addition logging destinations

Additional sinks can be installed separately if needed. Simply register the new sinks to the logging builder after package installation is complete.

```shell
# install Elasticsearch sink
dotnet add package Intility.Extensions.Logging.Elasticsearch

# install Sentry sink
dotnet add package Intility.Extensions.Logging.Sentry
```

```csharp
// Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseIntilityLogging((hostContext, logging) =>
{
logging.UseDefaultEnrichers()
.UseElasticsearch()
.UseSentry();
})
//...
```

```json
{
"Elasticsearch": {
"Endpoints": "localhost:9200",
"IndexFormat": "my-service-{0:yyyy.MM}"
},
"Sentry": {
"Dsn": "https://examplePublicKey@o0.ingest.sentry.io/0",
"MaxRequestBodySize": "Always",
"SendDefaultPii": true,
"MinimumBreadcrumbLevel": "Debug",
"MinimumEventLevel": "Warning",
"AttachStackTrace": true,
"Debug": true,
"DiagnosticsLevel": "Error"
}
}
```