Pacem.Extensions.Logging.SqlServer
0.8.11
See the version list below for details.
dotnet add package Pacem.Extensions.Logging.SqlServer --version 0.8.11
NuGet\Install-Package Pacem.Extensions.Logging.SqlServer -Version 0.8.11
<PackageReference Include="Pacem.Extensions.Logging.SqlServer" Version="0.8.11" />
<PackageVersion Include="Pacem.Extensions.Logging.SqlServer" Version="0.8.11" />
<PackageReference Include="Pacem.Extensions.Logging.SqlServer" />
paket add Pacem.Extensions.Logging.SqlServer --version 0.8.11
#r "nuget: Pacem.Extensions.Logging.SqlServer, 0.8.11"
#:package Pacem.Extensions.Logging.SqlServer@0.8.11
#addin nuget:?package=Pacem.Extensions.Logging.SqlServer&version=0.8.11
#tool nuget:?package=Pacem.Extensions.Logging.SqlServer&version=0.8.11
SqlServer Logging Extensions
⚗️ ==Experimental==
⚠️ Experimental libs are discouraged to use in production.
About
Pacem.Extensions.Loggin.SqlServer
provides extensions to store
your logs into a Sql Server 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:
TableAttribute
is recommended to correctly identify the target table.
Fallback, in case of missing attribute, isdbo.<LogEntityTypeName>
.ColumnAttribute
is 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 =>
{
if (!log.Name.StartsWith("Pacem."))
{
// by returning null you skip the log
return null;
}
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
};
});
Plans for version next
Multiple entities log.
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
- Microsoft.Data.SqlClient (>= 5.2.0)
- Pacem.Extensions.Logging (>= 0.8.11)
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.9.0-dirac | 43 | 8/2/2025 |
0.9.0-cayley | 90 | 7/31/2025 |
0.9.0-boyle | 89 | 7/31/2025 |
0.9.0-abel | 109 | 7/17/2025 |
0.8.11 | 160 | 5/27/2025 |
0.8.10 | 147 | 5/7/2025 |
0.8.10-fourier | 134 | 5/2/2025 |
0.8.10-fibonacci | 203 | 2/7/2025 |
0.8.10-fermat | 96 | 2/3/2025 |
0.8.10-euler | 91 | 2/3/2025 |
0.8.10-euclid | 97 | 2/1/2025 |
0.8.10-dalembert | 96 | 1/31/2025 |
0.8.10-cauchy | 98 | 1/26/2025 |
0.8.10-cantor | 104 | 12/18/2024 |
0.8.10-caccioppoli | 175 | 12/6/2024 |
0.8.10-bourbaki | 96 | 12/6/2024 |
0.8.10-abel | 113 | 4/22/2024 |
0.8.6 | 333 | 3/17/2024 |
0.8.6-abel | 103 | 3/14/2024 |
0.8.5 | 161 | 3/13/2024 |
0.8.4 | 121 | 3/12/2024 |
0.8.3 | 136 | 3/12/2024 |
0.8.2 | 134 | 3/11/2024 |
0.8.1 | 123 | 3/11/2024 |