Vestfold.Extensions.Logging
1.0.1
Prefix Reserved
dotnet add package Vestfold.Extensions.Logging --version 1.0.1
NuGet\Install-Package Vestfold.Extensions.Logging -Version 1.0.1
<PackageReference Include="Vestfold.Extensions.Logging" Version="1.0.1" />
<PackageVersion Include="Vestfold.Extensions.Logging" Version="1.0.1" />
<PackageReference Include="Vestfold.Extensions.Logging" />
paket add Vestfold.Extensions.Logging --version 1.0.1
#r "nuget: Vestfold.Extensions.Logging, 1.0.1"
#addin nuget:?package=Vestfold.Extensions.Logging&version=1.0.1
#tool nuget:?package=Vestfold.Extensions.Logging&version=1.0.1
Vestfold.Extensions.Logging
Contains builder extensions for configuring logging in a dotnet core application.
Usage in an Azure Function / Azure Web App
Azure App Services does not allow periods (.) in the app setting names.<br /> As a workaround, use an underscore (_) instead of a period (.) in the app setting names, and it will be handled correctly in the code.<br /> If an app setting contains a period, the period is replaced with an underscore (_) in the container.
Add the following to your local.settings.json
file:
All properties (except AzureWebJobsStorage
and FUNCTIONS_WORKER_RUNTIME
which is Azure specific) are optional.
Semi optional properties:
AppName
: If not set, the assembly name will be used as AppName property in logsVersion
: If not set, the assembly version will be used as Version property in logs
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AppName": "Name of your application, used as a property in the logs",
"BetterStack_SourceToken": "Your BetterStack source token",
"BetterStack_Endpoint": "https://foo.betterstackdata.com",
"BetterStack_MinimumLevel": "Information",
"MicrosoftTeams_WebhookUrl": "microsoft teams webhook url | microsoft power automate flow url if UseWorkflows is set to true",
"MicrosoftTeams_UseWorkflows": "true if Microsoft Power Automate flow is used, false if Microsoft Teams webhook is used (default is true)",
"MicrosoftTeams_TitleTemplate": "The title template of the card",
"MicrosoftTeams_MinimumLevel": "Warning",
"Version": "1.0.0"
}
}
Override minimum levels for certain namespaces
If you want to override a namespace which contains a period (.), for instance Microsoft.Hosting
,
you need to use an underscore (_) since Azure App Services does not allow periods (.) in the app setting names.
Example: Add an override for everything in the Microsoft.Hosting
namespace to log from Warning and higher
{
"Values": {
"Serilog_MinimumLevel_Override_Microsoft_Hosting": "Warning"
}
}
Usage outside Azure
Add the following to your appsettings.json
file:
All properties are optional.
Semi optional properties:
AppName
: If not set, the assembly name will be used as AppName property in logsVersion
: If not set, the assembly version will be used as Version property in logs
{
"AppName": "Name of your application, used as a property in the logs",
"BetterStack": {
"SourceToken": "Your BetterStack source token",
"Endpoint": "https://foo.betterstackdata.com",
"MinimumLevel": "Information"
},
"MicrosoftTeams": {
"WebhookUrl": "microsoft teams webhook url | microsoft power automate flow url if UseWorkflows is set to true",
"UseWorkflows": "true if Microsoft Power Automate flow is used, false if Microsoft Teams webhook is used (default is true)",
"TitleTemplate": "The title template of the card",
"MinimumLevel": "Warning"
},
"Version": "1.0.0"
}
Override minimum levels for certain namespaces
Example: Add an override for everything in the Microsoft.Hosting
namespace to log from Warning and higher
{
"Serilog": {
"MinimumLevel": {
"Override": {
"Microsoft.Hosting": "Warning"
}
}
}
}
Setting up logging for an Azure Function / Azure Web App
var builder = FunctionsApplication.CreateBuilder(args);
builder.ConfigureFunctionsWebApplication();
builder.Logging.AddVestfoldLogging();
builder.Build().Run();
Setting up logging for a HostBuilder (Console app, ClassLibrary, etc.)
public static async Task Main(string[] args)
{
await Host.CreateDefaultBuilder(args)
.ConfigureLogging(builder => builder.AddVestfoldLogging())
.Build()
.RunAsync();
await Serilog.Log.CloseAndFlushAsync();
}
Setting up logging for a WebApplicationBuilder (WebAPI, Blazor, etc.)
var builder = WebApplication.CreateBuilder(args);
builder.Logging.AddVestfoldLogging();
var app = builder.Build();
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
- BetterStack.Logs.Serilog (>= 1.1.0)
- Microsoft.Extensions.Configuration (>= 9.0.5)
- Microsoft.Extensions.DependencyInjection (>= 9.0.5)
- Microsoft.Extensions.Hosting (>= 9.0.5)
- Serilog (>= 4.3.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.GlobalLogContext (>= 3.0.0)
- Serilog.Extensions.Hosting (>= 9.0.0)
- Serilog.Extensions.Logging (>= 9.0.1)
- Serilog.Settings.Configuration (>= 9.0.0)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.MicrosoftTeams.Alternative (>= 1.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.