ChroniLog.Flusher.PostgreSql
1.0.7
dotnet add package ChroniLog.Flusher.PostgreSql --version 1.0.7
NuGet\Install-Package ChroniLog.Flusher.PostgreSql -Version 1.0.7
<PackageReference Include="ChroniLog.Flusher.PostgreSql" Version="1.0.7" />
<PackageVersion Include="ChroniLog.Flusher.PostgreSql" Version="1.0.7" />
<PackageReference Include="ChroniLog.Flusher.PostgreSql" />
paket add ChroniLog.Flusher.PostgreSql --version 1.0.7
#r "nuget: ChroniLog.Flusher.PostgreSql, 1.0.7"
#:package ChroniLog.Flusher.PostgreSql@1.0.7
#addin nuget:?package=ChroniLog.Flusher.PostgreSql&version=1.0.7
#tool nuget:?package=ChroniLog.Flusher.PostgreSql&version=1.0.7
<img src="https://raw.githubusercontent.com/sicilo/ChroniLog/master/ChroniLog.Core/logo.png" alt="ChroniLog Logo" width="150"/>
ChroniLog Flush PostgreSQL 🎯
Installation
Add the following NuGet packages to your project:
dotnet add package Npgsql
dotnet add package ChroniLog.Core
dotnet add package ChroniLog.Flusher.PostgreSql
Configuration
Register
appsettings.jsonconfigurationIn the code below, you can see
ChroniLogOptions, which is mandatory if you want to customize buffer and database table name options, andConnectionOptions, which is just an example for the next steps about how to provideNpgsqlDataSourceusing dependency injection.{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "ConnectionOptions": { "Database":"Host=<your_host>;Port=<your_port>;Database=<your_db>;Username=<your_user>;Password=<your_pass>" }, "ChroniLogOptions": { "BufferCapacity": 50, "BufferFlushInterval": 10, "TableName": "audit" } }Register
NpgsqlDataSourcewith Dependency Injection//ConnectionOptions appSettings Model public class ConnectionOptions { public string Database { get; set; } = null!; }//Configure ConnectionOptions public class ConfigureConnectionOptions(IConfiguration configuration) : IConfigureOptions<ConnectionOptions> { public void Configure(ConnectionOptions options) { configuration.GetSection(nameof(ConnectionOptions)).Bind(options); } }//Configure ConnectionOptions public static class DatabaseExtensions { public static IServiceCollection AddDatabase(this IServiceCollection builder) { builder.ConfigureOptions<ConfigureConnectionOptions>(); builder.AddSingleton<NpgsqlDataSource>(serviceProvider => { var options = serviceProvider.GetRequiredService<IOptions<ConnectionOptions>>().Value; var npgsqlDataSourceBuilder = new NpgsqlDataSourceBuilder(options.Database); return npgsqlDataSourceBuilder.Build(); }); return builder; } }//Program.cs var builder = WebApplication.CreateBuilder(args); builder.Services.AddDatabase();Register
AddNpgLogwith Dependency Injection//Program.cs var builder = WebApplication.CreateBuilder(args); builder.Services.AddDatabase(); builder.Logging.AddChroniLogFlushPostgreSql();
Notes
Npgsqlprovides PostgreSQL database handler.ChroniLog.Coreprovides the core logging infrastructure.ChroniLog.Flusher.PostgreSqlis the PostgreSQL-specific implementation.- Ensure your PostgreSQL database and connection string are properly configured.
| 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
- ChroniLog.Core (>= 2.0.0)
- Npgsql (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.