Pacem.Extensions.Logging.SqlServer
0.10.13-abel
See the version list below for details.
dotnet add package Pacem.Extensions.Logging.SqlServer --version 0.10.13-abel
NuGet\Install-Package Pacem.Extensions.Logging.SqlServer -Version 0.10.13-abel
<PackageReference Include="Pacem.Extensions.Logging.SqlServer" Version="0.10.13-abel" />
<PackageVersion Include="Pacem.Extensions.Logging.SqlServer" Version="0.10.13-abel" />
<PackageReference Include="Pacem.Extensions.Logging.SqlServer" />
paket add Pacem.Extensions.Logging.SqlServer --version 0.10.13-abel
#r "nuget: Pacem.Extensions.Logging.SqlServer, 0.10.13-abel"
#:package Pacem.Extensions.Logging.SqlServer@0.10.13-abel
#addin nuget:?package=Pacem.Extensions.Logging.SqlServer&version=0.10.13-abel&prerelease
#tool nuget:?package=Pacem.Extensions.Logging.SqlServer&version=0.10.13-abel&prerelease
SqlServer Logging Extensions
⚗️ ==Experimental==
⚠️ Experimental libs are discouraged to use in production.
About
Pacem.Extensions.Logging.SqlServer provides extensions to store
your logs into a Sql Server database.
Rows are written by a background consumer, so logging calls never block on the database.
The following paragraphs exemplify the library utilization given common use cases.
How to
Add the relevant logger provider to the logging builder (e.g. ILoggingBuilder).
First, define the target entity.
Exploit DataAnnotation like in attribute-based entity definitions (if you're familiar
with EntityFramework Core).
ℹ️ Please notice:
TableAttributeis recommended to correctly identify the target table.
Fallback, in case of missing attribute, isdbo.<LogEntityTypeName>.ColumnAttributeis mandatory in case of name mismatch between property and column, but optional otherwise.
If you want to ignore a property, decorate it with a
NotMappedAttribute.
// Structure of a log row in the [Logging].[Logs] table in the database
[Table("Logs", Schema = "Logging")]
public class MyLogEntity
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity), Key]
public int Id { get; set; }
[Required]
public required string Source { get; set; }
[Required]
public required string Message { get; set; }
[Column(TypeName = "tinyint")]
public LogLevel LogLevel { get; set; }
[Column(TypeName = "datetimeoffset(3)")]
public DateTimeOffset Timestamp { get; set; }
public string? ErrorMessage { get; set; }
public string? ErrorStack { get; set; }
public string? AllData { get; set; }
/// <summary>
/// Some relation to the business logic world "outside", if any.
/// </summary>
public Guid? RelationId { get; set; }
}
Then, configure the logger provider:
// Program.cs
builder.Logging.AddPacemSqlServerLogging<MyLogEntity>(
"sql-server-connectionstring-here",
// mapper: log line -> log entity
log =>
{
Guid? relationId = default;
if (log.Data?.TryGetValue("relation", out var relationObj) == true
&& Guid.TryParse(relationObj?.ToString(), out Guid result))
{
relationId = result;
}
return new MyLogEntity
{
Source = log.Name,
Timestamp = log.Timestamp,
Message = log.Message,
ErrorMessage = log.Exception?.Message,
ErrorStack = log.Exception?.StackTrace,
LogLevel = log.LogLevel,
AllData = JsonSerializer.Serialize(log.Data),
RelationId = relationId
};
},
// accumulate several rows into one INSERT (default: false)
batch: true,
// further options
configure: options =>
{
// only persist our own categories
options.Filter = log => log.Name.StartsWith("Pacem.");
});
ℹ️ The mapper may also return null to skip an entry, but
Filter is the preferred place for that decision: it runs earlier (on the
caller's thread, before the row is queued) and keeps the mapper about mapping only.
The log payload
The SqlServerLogPayload handed to the mapper and the filter exposes:
| Member | Notes |
|---|---|
Name |
Logger category. |
Timestamp |
When the entry was produced. |
LogLevel |
Severity. |
Message |
Formatted message. |
EventId |
The EventId passed to the logger, if any. |
Exception |
The associated exception, if any. |
Data |
The structured log values (message placeholders), as a dictionary. |
Plans for version next
Multiple entities log.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Data.SqlClient (>= 7.0.2)
- Pacem.Extensions.Logging (>= 0.10.13-abel)
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 |
|---|---|---|
| 0.10.14-boltzmann | 0 | 9/5/2026 |
| 0.10.13 | 45 | 9/3/2026 |
| 0.10.13-abel | 38 | 9/3/2026 |
| 0.10.12 | 37 | 9/3/2026 |
| 0.10.11 | 83 | 8/26/2026 |
| 0.10.10 | 104 | 7/28/2026 |
| 0.10.8 | 113 | 5/26/2026 |
| 0.10.8-carnot | 113 | 5/12/2026 |
| 0.10.8-cardano | 103 | 5/11/2026 |
| 0.10.8-bombelli | 94 | 5/6/2026 |
| 0.10.7 | 111 | 4/22/2026 |
| 0.10.7-rc | 108 | 4/22/2026 |
| 0.10.0-descartes | 122 | 1/19/2026 |
| 0.10.0-cramer | 129 | 1/13/2026 |
| 0.10.0-cotes | 121 | 1/13/2026 |
| 0.10.0-clapeyron | 121 | 1/12/2026 |
| 0.10.0-cauchy | 124 | 1/12/2026 |
| 0.10.0-boyle | 130 | 12/30/2025 |
| 0.10.0-abel | 217 | 12/4/2025 |
| 0.9.14 | 596 | 12/1/2025 |