StructLog 1.0.0
dotnet add package StructLog --version 1.0.0
NuGet\Install-Package StructLog -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="StructLog" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StructLog" Version="1.0.0" />
<PackageReference Include="StructLog" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StructLog --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StructLog, 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.
#:package StructLog@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StructLog&version=1.0.0
#tool nuget:?package=StructLog&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
StructLog
A modern structured logging library for .NET with support for custom enrichers, JSON logging, and full Dependency Injection integration.
✨ Features
- 🔧 Structured logs with JSON output
- 🌐 DI-ready: works with
ILogger<T>andIOptions<StructLogOptions> - ⚡ Custom Enrichers support (
ILogEnricher) - 📝 Configurable options via
appsettings.json - 🖥️ Works in Console, Worker, and ASP.NET Core apps
📋 Requirements
| Requirement | Minimum Version |
|---|---|
| .NET | 9.0+ |
🚀 Installation
dotnet add package StructLog
🎯 Quick Start
1. Configure appsettings.json
{
"StructLog": {
"EnableEnrichers": true
}
}
2. Register Services
// With config
builder.Services.AddStructLog(builder.Configuration);
// Only defaults (Without appsettings)
builder.Services.AddStructLog();
3. Exemple Usage
[ApiController]
public class UserController : ControllerBase
{
private readonly IStructLog<UserController> _logger;
public UsersController(IStructLog<UserController> logger)
{
_logger = logger;
}
[HttpGet]
public async Task<IActionResult> GetUsers()
{
var user = await GetUserFromId(1);
if(user == null)
{
_logger.Warning("User not found", new EventCode("TEST_001", "Get user event"), new { UserId = 1 });
return NotFound();
}
_logger.info("User retrieved successfully", new EventCode("TEST_002", "Get user event"), user);
return Ok(user);
}
}
4. Exemple Log Output
{
"EventId": 0,
"LogLevel": "Information",
"Category": "Program",
"Message": {
"EventCode": "TEST_002",
"EventDescription": "Get user event",
"Message": "User retrieved successfully",
"Context": {
"MachineName": "Exemple-Machine-01"
},
"Data": {
"Id": 1,
"Name": "Exemple",
"Surname": "Exemple",
"Birthday": "1990-01-01T00:00:00"
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.Configuration (>= 10.0.3)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 45 | 2/27/2026 |