Ozcorps.Logger
9.0.0
dotnet add package Ozcorps.Logger --version 9.0.0
NuGet\Install-Package Ozcorps.Logger -Version 9.0.0
<PackageReference Include="Ozcorps.Logger" Version="9.0.0" />
<PackageVersion Include="Ozcorps.Logger" Version="9.0.0" />
<PackageReference Include="Ozcorps.Logger" />
paket add Ozcorps.Logger --version 9.0.0
#r "nuget: Ozcorps.Logger, 9.0.0"
#:package Ozcorps.Logger@9.0.0
#addin nuget:?package=Ozcorps.Logger&version=9.0.0
#tool nuget:?package=Ozcorps.Logger&version=9.0.0
Ozcorps.Logger
A modular, extensible logging library for ASP.NET Core applications. Routes logs to Text files, RabbitMQ, Logstash (ELK), or OTLP-compatible backends (Grafana, Aspire Dashboard) through a single IOzLogger interface.
Installation
dotnet add package Ozcorps.Logger
Backends
| Extension | Description |
|---|---|
AddOzTextLogger |
Writes logs to text files |
AddOzRabbitMqLogger |
Publishes logs to RabbitMQ queues |
AddOzLogstashLogger |
Sends logs to Logstash (ELK Stack) |
AddOzOtlpLogger |
Exports logs via OTLP to Grafana, Aspire Dashboard, etc. |
Text Logger
// Program.cs
builder.Services.AddOzTextLogger();
// appsettings.json
{
"Logging": {
"Directory": {
"TextLogger": "/var/logs/myapp"
}
}
}
RabbitMQ Logger
// Program.cs
builder.Services.AddOzRabbitMqLogger();
// appsettings.json
{
"RabbitMq": {
"HostName": "localhost",
"Username": "admin",
"Password": "admin",
"VirtualHost": "/"
},
"RabbitMqLogger": {
"UserLogQueue": "myapp-user-logs",
"AuditLogQueue": "myapp-audit-logs",
"ActionLogQueue": "myapp-action-logs",
"OtherLogQueue": "myapp-other-logs"
}
}
Logstash Logger (ELK)
// Program.cs
builder.Services.AddOzLogstashLogger();
// appsettings.json
{
"Logging": {
"Logstash": {
"Host": "localhost",
"Port": 5000,
"Protocol": "tcp",
"ApplicationName": "MyApp",
"Enabled": true,
"ActionIndexName": "myapp-action-logs",
"UserIndexName": "myapp-user-logs",
"AuditIndexName": "myapp-audit-logs",
"OtherIndexName": "myapp-other-logs"
}
}
}
OTLP Logger (Grafana / Aspire Dashboard)
// Program.cs
builder.Services.AddOzOtlpLogger();
builder.Services.AddOpenTelemetry()
.WithLogging(b => b.AddOtlpExporter(o =>
{
o.Endpoint = new Uri(builder.Configuration["OpenTelemetry:Endpoint"]!);
}));
// appsettings.json
{
"OpenTelemetry": {
"Endpoint": "http://localhost:4317"
}
}
Log categories used by OtlpLogger: OzLogger.Error, OzLogger.Warning, OzLogger.Debug, OzLogger.User, OzLogger.Audit, OzLogger.Action
Usage
All backends share the same IOzLogger interface:
public class OrderController : ControllerBase
{
private readonly IOzLogger _logger;
public OrderController(IOzLogger logger) => _logger = logger;
[HttpPost]
public async Task<IActionResult> Create(OrderRequest request)
{
try
{
// ...
await _logger.ActionAsync(new ActionLog
{
ControllerName = "Order",
ActionName = "Create",
Message = "Order created",
UserId = GetUserId(),
Username = User.Identity!.Name
});
return Ok();
}
catch (Exception ex)
{
await _logger.ErrorAsync(ex, "Order creation failed",
_ip: HttpContext.Connection.RemoteIpAddress?.ToString(),
_username: User.Identity?.Name,
_userId: GetUserId());
return StatusCode(500);
}
}
}
Log Types
// Error
_logger.Error(ex, "message",
_ip: "...", _username: "...", _userId: 1,
_className: "OrderService", _functionName: "Create");
// Warning
_logger.Warning("message", _ip: "...", _username: "...", _userId: 1);
// Debug
_logger.Debug("message", _ip: "...", _username: "...", _userId: 1);
// User activity (login / logout)
_logger.User(new UserLog
{
UserId = 1,
Username = "oz",
UserIpAddress = "127.0.0.1",
UserRoles = "admin",
UserLogType = UserLogType.LogIn, // WrongLogIn | LogIn | LogOut
Date = DateTime.UtcNow
});
// Controller action (automatic or manual)
_logger.Action(new ActionLog
{
UserId = 1,
Username = "oz",
UserIpAddress = "127.0.0.1",
ControllerName = "Order",
ActionName = "Create",
Message = "Order created",
Date = DateTime.UtcNow
});
// Database change tracking
_logger.Audit(new List<AuditLog>
{
new AuditLog
{
Entity = "Product",
EntityId = 42,
Table = "products",
Operation = "Update",
Json = "{...}",
UserId = 1,
Username = "oz",
Date = DateTime.UtcNow
}
});
Automatic Action Logging with OzLoggerActionFilter
OzLoggerActionFilter automatically captures each controller action and logs it. It reads user identity from the following HTTP request headers:
| Header | Description |
|---|---|
ozt-user-id |
Numeric user ID |
ozt-username |
Username |
ozt-roles |
User roles |
// Program.cs — global (all controllers)
builder.Services.AddControllers(options =>
options.Filters.Add<OzLoggerActionFilter>());
// Per-controller or per-action
[OzLoggerActionFilter]
public class ProductController : ControllerBase { ... }
Requirements
- .NET 8.0+
Ozcorps.Core 8.0.0Ozcorps.Tools 8.0.0(required byAddOzRabbitMqLogger)
| 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.AspNetCore.Mvc (>= 2.2.0)
- Ozcorps.Core (>= 8.0.0)
- Ozcorps.Tools (>= 8.0.0)
- System.Security.Cryptography.Pkcs (>= 8.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Ozcorps.Logger:
| Package | Downloads |
|---|---|
|
Ozcorps.Logger.Db.Postgre
Package Description |
|
|
Ozcorps.Logger.Db.Mssql
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0 | 94 | 4/7/2026 |
| 8.1.2 | 152 | 3/11/2026 |
| 8.1.1 | 1,111 | 1/22/2026 |
| 8.1.0 | 353 | 1/21/2026 |
| 8.0.0 | 6,506 | 11/26/2024 |
| 2.3.0 | 2,958 | 10/17/2024 |
| 2.2.1 | 1,073 | 8/22/2024 |
| 2.2.0 | 257 | 8/19/2024 |
| 2.1.0 | 1,072 | 5/23/2024 |
| 2.0.3 | 226 | 5/6/2024 |
| 2.0.2 | 249 | 2/28/2024 |
| 2.0.1 | 336 | 12/1/2023 |
| 2.0.0 | 4,581 | 6/23/2023 |
| 1.2.4 | 507 | 12/14/2023 |
| 1.2.3 | 264 | 12/12/2023 |
| 1.2.2 | 1,579 | 4/7/2023 |
| 1.2.1 | 355 | 4/7/2023 |
| 1.2.0 | 351 | 4/6/2023 |
| 1.1.1 | 911 | 11/29/2022 |
| 1.1.0 | 579 | 11/25/2022 |