SELISE_BD.LOGGER.PERIODIC 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SELISE_BD.LOGGER.PERIODIC --version 1.0.0                
NuGet\Install-Package SELISE_BD.LOGGER.PERIODIC -Version 1.0.0                
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="SELISE_BD.LOGGER.PERIODIC" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SELISE_BD.LOGGER.PERIODIC --version 1.0.0                
#r "nuget: SELISE_BD.LOGGER.PERIODIC, 1.0.0"                
#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.
// Install SELISE_BD.LOGGER.PERIODIC as a Cake Addin
#addin nuget:?package=SELISE_BD.LOGGER.PERIODIC&version=1.0.0

// Install SELISE_BD.LOGGER.PERIODIC as a Cake Tool
#tool nuget:?package=SELISE_BD.LOGGER.PERIODIC&version=1.0.0                

Logging Setup and Configuration

This guide will walk you through the steps to set up advanced logging in your application using Serilog, Seq, and a periodic logging service.

AppSettings Configuration Add the following settings to your appsettings.json file:

{
  "LogTracker": {
    "OrganizationId": "aec74b36-d2da-4cd4-9cd1-abde7d23553c",
    "ApplicationId": "f0d91e36-95c6-42fd-93be-2b2e7bc066d0",
    "ApiUrl": "http://localhost:5006/"
  },
  "Seq": {
    "SeqServerUrl": "http://host.docker.internal:5341",
    "SeqApiKey": "FcUQ9ujzJGvFK7gvRkrj"
  },
  "PeriodicLogger": {
    "SyncIntervalMinutes": 5
  }
}

Logger Registration

Add the following code to register the logger in your Program.cs or Startup.cs file:

using Serilog;
using Serilog.Core;

// Create a level switch for controlling logging levels
var levelSwitch = new LoggingLevelSwitch();

// Configure Serilog for real-time file logging with date in file name
Log.Logger = new LoggerConfiguration()
    .MinimumLevel.ControlledBy(levelSwitch)
    .Enrich.FromLogContext()
    .Enrich.WithProperty("ApplicationName", builder.Environment.ApplicationName)
    .Enrich.WithProperty("EnvironmentName", builder.Environment.EnvironmentName)
    .WriteTo.Console()
    .WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day) // Real-time file logging with date
    .CreateLogger();

builder.Host.UseSerilog(Log.Logger);

Register Dependencies

Register the necessary dependencies in your Program.cs or Startup.cs file:

builder.Services.AddHostedService<PeriodicLoggerService>(); // Register the background service for periodic logging
builder.Services.AddSingleton(levelSwitch); // Register LoggingLevelSwitch as a singleton service
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.1 106 6/11/2024
1.0.0 108 6/9/2024