HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL
1.0.1
Prefix Reserved
See the version list below for details.
dotnet add package HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL --version 1.0.1
NuGet\Install-Package HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL -Version 1.0.1
<PackageReference Include="HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL" Version="1.0.1" />
paket add HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL --version 1.0.1
#r "nuget: HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL, 1.0.1"
// Install HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL as a Cake Addin #addin nuget:?package=HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL&version=1.0.1 // Install HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL as a Cake Tool #tool nuget:?package=HaemmerElectronics.SeppPenner.SerilogSinkForPostgreSQL&version=1.0.1
SerilogSinkForPostgreSQL
SerilogSinkForPostgreSQL is a library to save logging information from Serilog to PostgreSQL. The assembly was written and tested in .Net Framework 4.8 and .Net Standard 2.0.
Available for
- NetFramework 4.5
- NetFramework 4.6
- NetFramework 4.6.2
- NetFramework 4.7
- NetFramework 4.7.2
- NetFramework 4.8
- NetStandard 2.0
Basic usage:
string connectionString = "User ID=serilog;Password=serilog;Host=localhost;Port=5432;Database=Logs";
string tableName = "logs";
IDictionary<string, ColumnWriterBase> columnWriters = new Dictionary<string, ColumnWriterBase>
{
{ "message", new RenderedMessageColumnWriter(NpgsqlDbType.Text) },
{ "message_template", new MessageTemplateColumnWriter(NpgsqlDbType.Text) },
{ "level", new LevelColumnWriter(true, NpgsqlDbType.Varchar) },
{ "raise_date", new TimestampColumnWriter(NpgsqlDbType.Timestamp) },
{ "exception", new ExceptionColumnWriter(NpgsqlDbType.Text) },
{ "properties", new LogEventSerializedColumnWriter(NpgsqlDbType.Jsonb) },
{ "props_test", new PropertiesColumnWriter(NpgsqlDbType.Jsonb) },
{ "machine_name", new SinglePropertyColumnWriter("MachineName", PropertyWriteMethod.ToString, NpgsqlDbType.Text, "l") }
};
var logger = new LoggerConfiguration()
.WriteTo.PostgreSQL(connectionString, tableName, columnWriters)
.CreateLogger();
The project can be found on nuget.
Table auto creation:
If you set parameter needAutoCreateTable
to true
, the sink will automatically create the table.
string connectionString = "User ID=serilog;Password=serilog;Host=localhost;Port=5432;Database=Logs";
string tableName = "logs";
IDictionary<string, ColumnWriterBase> columnWriters = new Dictionary<string, ColumnWriterBase>
{
{ "message", new RenderedMessageColumnWriter(NpgsqlDbType.Text) },
{ "message_template", new MessageTemplateColumnWriter(NpgsqlDbType.Text) },
{ "level", new LevelColumnWriter(true, NpgsqlDbType.Varchar) },
{ "raise_date", new TimestampColumnWriter(NpgsqlDbType.Timestamp) },
{ "exception", new ExceptionColumnWriter(NpgsqlDbType.Text) },
{ "properties", new LogEventSerializedColumnWriter(NpgsqlDbType.Jsonb) },
{ "props_test", new PropertiesColumnWriter(NpgsqlDbType.Jsonb) },
{ "machine_name", new SinglePropertyColumnWriter("MachineName", PropertyWriteMethod.ToString, NpgsqlDbType.Text, "l") }
};
var logger = new LoggerConfiguration()
.WriteTo.PostgreSQL(connectionString, tableName, columnWriters, needAutoCreateTable: true)
.CreateLogger();
You can change column sizes by setting the values in the TableCreator
class:
// Sets size of all BIT and BIT VARYING columns to 20
TableCreator.DefaultBitColumnsLength = 20;
// Sets size of all CHAR columns to 30
TableCreator.DefaultCharColumnsLength = 30;
// Sets size of all VARCHAR columns to 50
TableCreator.DefaultVarcharColumnsLength = 50;
Mixed case table or column names
Table or column names are always case-sensitive!
Further information:
This project is a fork of https://github.com/b00ted/serilog-sinks-postgresql but is maintained. Do not hesitate to create issues or pull requests.
Change history
- Version 1.0.1.0 (2019-05-08) : Updated documentation, added documentation to the nuget package and all classes, added option to allow upper case table and column names. Simplified building and packing scripts. Added support for NetFramework 4.6, NetFramework 4.6.2, NetFramework 4.7 and NetFramework 4.8.
- Version 1.0.0.0 (2019-02-22) : 1.0 release.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 is compatible. net463 was computed. net47 is compatible. net471 was computed. net472 is compatible. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
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 | |
---|---|---|---|
3.3.7 | 155,600 | 8/29/2021 | |
3.3.6 | 4,913 | 8/9/2021 | |
3.3.5 | 1,370 | 7/25/2021 | |
3.3.4 | 31,956 | 6/4/2021 | |
3.3.3 | 10,159 | 4/29/2021 | |
3.3.2 | 27,537 | 3/4/2021 | |
3.3.1 | 2,682 | 3/4/2021 | |
3.3.0 | 1,836 | 2/21/2021 | |
3.2.4 | 143 | 2/21/2021 | |
3.2.3 | 5,955 | 1/14/2021 | |
3.2.2 | 1,863 | 1/4/2021 | |
3.2.1 | 469 | 1/3/2021 | |
3.2.0 | 541 | 12/26/2020 | |
3.1.0 | 1,230 | 11/16/2020 | |
3.0.0 | 2,455 | 11/11/2020 | |
2.5.0 | 782 | 10/13/2020 | |
2.4.1 | 209 | 10/13/2020 | |
2.4.0 | 4,507 | 9/6/2020 | |
2.3.1 | 279 | 9/6/2020 | |
2.3.0 | 586 | 9/6/2020 | |
2.2.0 | 7,451 | 7/25/2020 | |
2.1.0 | 130,345 | 6/30/2020 | |
2.0.0 | 1,191 | 6/16/2020 | |
1.9.0 | 548 | 6/16/2020 | |
1.8.1 | 569 | 6/5/2020 | |
1.7.0 | 7,508 | 5/10/2020 | |
1.6.0 | 8,863 | 3/26/2020 | |
1.5.0 | 12,683 | 2/9/2020 | |
1.0.4 | 13,268 | 11/8/2019 | |
1.0.3 | 1,032 | 6/23/2019 | |
1.0.2 | 707 | 5/13/2019 | |
1.0.1 | 640 | 5/12/2019 | |
1.0.0 | 636 | 2/22/2019 |
Version 1.0.1.0 (2019-02-23)** : Updated documentation, added documentation to the nuget package and all classes, added option to allow upper case table and column names.
Version 1.0.0.0 (2019-02-22)** : 1.0 release.