CerbiStream 1.1.1
dotnet add package CerbiStream --version 1.1.1
NuGet\Install-Package CerbiStream -Version 1.1.1
<PackageReference Include="CerbiStream" Version="1.1.1" />
<PackageVersion Include="CerbiStream" Version="1.1.1" />
<PackageReference Include="CerbiStream" />
paket add CerbiStream --version 1.1.1
#r "nuget: CerbiStream, 1.1.1"
#addin nuget:?package=CerbiStream&version=1.1.1
#tool nuget:?package=CerbiStream&version=1.1.1
CerbiStream: Dev-Friendly, Governance-Enforced Logging for .NET
đ View CerbiStream Benchmarks
Compare against Serilog, NLog, and others. CerbiStream is engineered for high performance, strict governance, and enterprise-grade log routing.
Table of Contents
- Overview
- Highlights
- Features
- Architecture & Implementation
- Preset Modes and Configuration
- Usage Examples
- Integration & Supported Platforms
- Governance and Compliance
- Telemetry Provider Support
- Unit Testing
- Cerbi Suite: The Bigger Picture
- Contributing
- License
đ Recent Updates (v1.1.0)
New Features
Unified Log Enrichment:
Every log message is now enriched with a unique LogId (GUID), timestamp, ApplicationId, InstanceId, CloudProvider, Region, and any additional metadata. All of this information is embedded directly in the JSON payload.Dual Metadata Transmission:
The enriched JSON payload is sent along with a separate LogId parameter. This allows for:- Efficient Routing & Partitioning: The separate LogId is used as a partition key (or similar) by the queue implementations.
- Simplified Tracing: Console or debug logs show the LogId immediately without needing to re-parse the JSON.
Resilient Queue Sending:
With the use of Polly, transient failures are automatically retried up to 3 times with exponential backoff. This resiliency is applied transparently to the selected queue implementation when enabled.
Breaking Changes (v1.1.0)
Consolidation of Queue Interfaces:
- Removed: The old
IQueue
interface (which definedSendMessageAsync(string, Guid)
). - Now Using: The new
ISendMessage
interface which defines:
All queue implementations have been updated to use this new signature.Task<bool> SendMessageAsync(string payload, string logId);
- Removed: The old
Log Message Enrichment:
- The logger now generates a unique
LogId
once per log entry. This ID is embedded within the JSON payload along with metadata (timestamp, ApplicationId, etc.) and is also passed as a separate parameter. - This change means that downstream systems will receive a self-contained JSON log that includes the LogId, but the queue sender can also use the separate LogId for routing/partitioning purposes.
- The logger now generates a unique
Dependency Injection Changes:
- The logging pipeline now expects an implementation of
ISendMessage
instead ofIQueue
. If you have custom implementations that previously implementedIQueue
, these must be updated or replaced with the newISendMessage
-based implementation.
- The logging pipeline now expects an implementation of
Version Bump:
- The library version has been changed from 1.0.17 to 1.1.0 to reflect these major breaking changes.
How to Upgrade
Update Your DI Registrations:
If you previously registered your queue implementations using theIQueue
interface, change them to register asISendMessage
. For example:// Old registration: services.AddTransient<IQueue, AzureServiceBusQueue>(); // New registration: services.AddTransient<ISendMessage, AzureServiceBusQueue>();
Additionally, if you're using the resilient decorator, update it accordingly:
// Using Scrutor for decoration (if enabled) services.Decorate<ISendMessage, ResilientQueueClient>();
Update Logging Method Calls:
All log messages must now be enriched by the logger to include the LogId and other metadata inside the JSON payload. The logger then calls:await _queue.SendMessageAsync(formattedLog, logId);
Update your custom logging code accordingly if you're interfacing directly with these methods.
Example Usage
Below is an example of how the updated logger now works:
private async Task<bool> SendLog(object logEntry)
{
// Generate a unique LogId once per log entry.
string logId = Guid.NewGuid().ToString();
var enrichedLogEntry = new
{
LogId = logId,
TimestampUtc = DateTime.UtcNow,
ApplicationId = ApplicationMetadata.ApplicationId,
InstanceId = ApplicationMetadata.InstanceId,
CloudProvider = ApplicationMetadata.CloudProvider,
Region = ApplicationMetadata.Region,
LogData = logEntry
};
string formattedLog = _jsonConverter.ConvertMessageToJson(enrichedLogEntry);
_logger.LogInformation($"Log with ID {logId} sent to queue.");
// Send the enriched log payload with the LogId passed separately.
return await _queue.SendMessageAsync(formattedLog, logId);
}
Summary
These breaking changes and enhancements make the logging solution more robust, self-contained, and easier to trace and process downstream. We recommend upgrading to version 1.1.0 to take advantage of these improvements.
If you encounter any issues or need further assistance during the upgrade, please refer to our detailed migration guide or contact me.
This updated README and breaking changes section should help users understand the new design and what they need to update in their code. Let me know if you need any more adjustments or additional sections!
đ Encrypted File Logging & Rotation (Fallback Mode)
- Added
EncryptedFileRotator
with support for:- File size & age-based rotation
- AES encryption with configurable keys/IVs
- Archive naming with timestamped
.enc
files
- Background task service (
EncryptedFileRotationService
) for automatic, periodic rotation - Configurable via
FileFallbackOptions
:MaxFileSizeBytes
MaxFileAge
EncryptionKey
EncryptionIV
đ§Ș Unit Test Coverage
- Increased to ~65.5%
- Added test coverage for:
- Fallback logger pipeline
- Rotation trigger behavior
- Telemetry factory mapping
đ Upcoming Work
- FIPS toggle evaluation
- GitHub Copilot hints for governance rules
Overview
CerbiStream is a high-performance, dev-friendly logging framework for .NET that not only emphasizes low latency and high throughput but also enforces structured logging governance. Designed for modern applications using ILogger<T>
, CerbiStream integrates seamlessly into ASP.NET Core, Blazor, and Entity Framework projects. Its flexible configuration options and robust governance support make it ideal for both development and enterprise-scale deployments.
CerbiStream is a core component of the Cerbi Suiteâa set of tools designed for observability, log governance, routing, and telemetry in regulated and performance-critical environments.
Highlights
Dev-Friendly & Flexible:
Works out of the box with .NET Coreâs logging abstractions.High Performance:
Engineered for low latency and high throughput with efficient resource usage even when logs are output in realistic development modes.Governance-Enforced Logging:
Ensures logs conform to structured formats and compliance requirements via internal or pluggable governance validators.Multiple Integration Options:
Supports RabbitMQ, Kafka, Azure Service Bus, AWS SQS/Kinesis, and Google Pub/Sub.Encryption & Security:
Offers flexible encryption modesâincluding Base64 and AESâto secure sensitive logging data.Queue-First Architecture:
Decouples log generation from delivery, enhancing resilience and scalability via the CerbIQ routing component.Telemetry & Analytics:
Built-in support for telemetry providers (OpenTelemetry, Azure App Insights, AWS CloudWatch, etc.) for end-to-end observability.
Features
Developer Modes:
- EnableDevModeMinimal(): Minimal console logging without metadata injectionâperfect for lightweight development debugging.
- EnableDeveloperModeWithoutTelemetry(): Console logging with metadata injection but no telemetry data.
- EnableDeveloperModeWithTelemetry(): Full-fledged logging with metadata, telemetry, and governance checks.
- EnableBenchmarkMode(): A silent mode disabling all outputs, enrichers, and telemetry, ideal for performance measurement.
Governance Enforcement:
Use built-in or externally provided validators (via the CerbiStream.GovernanceAnalyzer or custom hooks) to enforce required log fields and format consistency.Encryption Options:
Configure encryption modes to secure log data with options for None, Base64, or AES encryption.Queue-First, Sink-Agnostic Logging:
Route logs through configured messaging queues first for enhanced fault tolerance and delayed sink processing via CerbIQ.Telemetry Integration:
Out-of-the-box support for major telemetry platforms ensures your log data is immediately useful for observability and diagnostics.
Architecture & Implementation
CerbiStreamâs architecture is designed to maximize logging performance while ensuring compliance and structured data integrity:
Asynchronous Processing:
The logging pipeline is built using modern asynchronous patterns to avoid blocking I/O. This allows high-volume log generation without impacting application performance.Queue-First Model:
Log events are first enqueued (supporting various messaging systems) before being dispatched to the final sink. This decoupling reduces processing spikes and improves reliability.Modular & Configurable:
The framework uses a fluent API for configuration, letting you easily switch modes, enable encryption, set up telemetry, and plug in custom governance validators.Governance & Validation:
A key aspect of CerbiStream is its governance engine, which enforces structured logging policies. Whether integrated via CerbiStream.GovernanceAnalyzer or custom logic, it ensures that all log messages meet your organizational standards.Performance Modes:
Different preset modes (Benchmark, Developer Modes) allow you to choose the level of output and enrichment based on your environmentâfrom raw performance testing to full-featured dev logging.
Preset Modes and Configuration
Developer Modes
EnableDevModeMinimal()
Minimal logging output to the console without metadata or governance checks.builder.Logging.AddCerbiStream(options => options.EnableDevModeMinimal());
EnableDeveloperModeWithoutTelemetry()
Console logging with metadata injection but without telemetry.builder.Logging.AddCerbiStream(options => options.EnableDeveloperModeWithoutTelemetry());
EnableDeveloperModeWithTelemetry()
Full developer mode with metadata enrichment and telemetry.builder.Logging.AddCerbiStream(options => options.EnableDeveloperModeWithTelemetry());
Benchmark Mode
- EnableBenchmarkMode()
Disables all outputs and enrichments for pure performance testing.builder.Logging.AddCerbiStream(options => options.EnableBenchmarkMode());
Advanced Customization
Queue Configuration:
options.WithQueue("RabbitMQ", "localhost", "logs-queue");
Encryption:
options.WithEncryptionMode(EncryptionType.AES)
.WithEncryptionKey(myKey, myIV);
Governance Validator:
options.WithGovernanceValidator((profile, log) =>
{
return log.ContainsKey("UserId") && log.ContainsKey("IPAddress");
});
Feature Toggles:
options.WithTelemetryLogging(true)
.WithConsoleOutput(true)
.WithMetadataInjection(true)
.WithGovernanceChecks(true);
Usage Examples
Basic Example
var builder = WebApplication.CreateBuilder(args);
builder.Logging.AddCerbiStream(options =>
{
options.EnableDevModeMinimal();
});
var app = builder.Build();
app.Run();
Developer Mode with Custom Queue and Encryption
builder.Logging.AddCerbiStream(options =>
{
options.WithQueue("Kafka", "broker-address", "app-logs")
.WithEncryptionMode(EncryptionType.Base64)
.EnableDeveloperModeWithoutTelemetry();
});
Full Mode with Telemetry and Governance
builder.Logging.AddCerbiStream(options =>
{
options
.WithQueue("AzureServiceBus", "sb://myservicebus.servicebus.windows.net", "logs-queue")
.WithEncryptionMode(EncryptionType.AES)
.WithGovernanceValidator((profile, log) =>
{
return log.ContainsKey("UserId") && log.ContainsKey("IPAddress");
})
.EnableDeveloperModeWithTelemetry();
});
File Fallback Logging with Encrypted Rotation
CerbiStream can automatically fallback to a local file logger if upstream log delivery fails. You can configure size/age-based rotation with optional AES encryption for compliance.
Enable Fallback in Your Program.cs or Startup.cs
builder.Logging.AddCerbiStream(options =>
{
options.EnableDevModeMinimal(); // Or Prod/Custom config
options.FileFallback = new FileFallbackOptions
{
Enable = true,
PrimaryFilePath = "logs/primary.json",
FallbackFilePath = "logs/fallback.json",
RetryCount = 3,
RetryDelay = TimeSpan.FromMilliseconds(250),
MaxFileSizeBytes = 5 * 1024 * 1024, // Rotate at 5MB
MaxFileAge = TimeSpan.FromMinutes(10), // Or age-based
EncryptionKey = "your-32-char-AES-key-here!!",
EncryptionIV = "your-16byte-iv"
};
});
Add Background Rotation Service
Make sure to register the rotation background service if you're using fallback:
builder.Services.AddHostedService<EncryptedFileRotationService>();
Integration & Supported Platforms
CerbiStream is designed to work in a variety of environments:
Messaging Queues:
Supports RabbitMQ, Kafka, Azure Service Bus, AWS SQS/Kinesis, and Google Pub/Sub.
Telemetry Providers:
Provider | Supported |
---|---|
OpenTelemetry | â |
Azure App Insights | â |
AWS CloudWatch | â |
GCP Trace | â |
Datadog | â |
Pluggable Sinks:
CerbiStream is âsink-agnosticâ â logs are initially routed to queues, and you can integrate downstream tools (e.g., CerbIQ) to manage final delivery to systems such as Splunk, Elasticsearch, or Blob Storage.
Governance and Compliance
A key differentiator of CerbiStream is its built-in governance:
Structured Logging Enforcement:
Ensures that every log entry adheres to predefined schemas for consistency, aiding in compliance with regulatory standards (e.g., HIPAA, GDPR).
External Governance Hook:
If needed, you can provide your own governance validator:
options.WithGovernanceValidator((profile, log) =>
{
return log.ContainsKey("UserId") && log.ContainsKey("IPAddress");
});
Optional CerbiStream.GovernanceAnalyzer:
An add-on package that performs static code analysis to ensure that logging policies are consistently followed.
Telemetry Provider Support
CerbiStream integrates seamlessly with popular telemetry systems to provide extended observability:
Supported providers include: OpenTelemetry, Azure App Insights, AWS CloudWatch, GCP Trace, and Datadog.
Configuration is straightforward through the fluent API, ensuring that enriched log data is automatically forwarded to your chosen telemetry platform.
Unit Testing
Example unit test for CerbiStream logging:
var mockQueue = Substitute.For<IQueue>();
var logger = new CerbiLoggerBuilder()
.WithQueue("TestQueue", "localhost", "unit-test-logs")
.UseNoOpEncryption()
.Build(mockQueue);
var result = await logger.LogEventAsync("Test log event", LogLevel.Information);
Assert.True(result);
Cerbi Suite: The Bigger Picture
CerbiStream is a core component of the Cerbi suiteâa broader ecosystem aimed at providing enterprise-grade observability, governance, and log routing solutions. The suite includes:
- CerbiStream: For high-performance, governance-enforced logging.
- CerbIQ: For advanced log routing, aggregation, and delivery to various sinks.
- CerbiStream.GovernanceAnalyzer: For static and runtime validation ensuring consistent log compliance.
Contributing
Contributions are welcome!
- Report Bugs or Request Features: Open an issue on GitHub.
- Submit Pull Requests: Follow our code style guidelines and ensure tests pass.
- Join the Community: Star the repo, share feedback, and help improve CerbiStream.
License
This project is licensed under the MIT License.
Star the repo â | Contribute đ§ | File issues đ
Created by @Zeroshi
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. |
-
net8.0
- AWSSDK.CloudWatchLogs (>= 3.7.410.20)
- AWSSDK.Kinesis (>= 3.7.402.109)
- AWSSDK.SQS (>= 3.7.400.132)
- Azure.Core (>= 1.45.0)
- Azure.Messaging.ServiceBus (>= 7.19.0)
- Azure.Storage.Common (>= 12.23.0)
- Azure.Storage.Queues (>= 12.22.0)
- cerberus-logger-interface (>= 1.0.26)
- Datadog.Trace (>= 3.14.3)
- Google.Cloud.Logging.V2 (>= 4.4.0)
- Google.Cloud.PubSub.V1 (>= 3.24.0)
- Google.Protobuf (>= 3.30.2)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.4)
- Moq (>= 4.20.72)
- NUnit (>= 4.3.2)
- OpenTelemetry (>= 1.11.2)
- OpenTelemetry.Exporter.Console (>= 1.11.2)
- Polly (>= 8.5.2)
- RabbitMQ.Client (>= 7.1.2)
- System.Configuration.ConfigurationManager (>= 9.0.4)
- System.Data.SqlClient (>= 4.9.0)
- System.Diagnostics.EventLog (>= 9.0.4)
- System.Security.Cryptography.ProtectedData (>= 9.0.4)
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.1.1 | 44 | 4/13/2025 |
1.1.0 | 50 | 4/13/2025 |
1.0.16 | 124 | 4/10/2025 |
1.0.15 | 124 | 4/7/2025 |
1.0.14 | 69 | 4/6/2025 |
1.0.13 | 102 | 3/28/2025 |
1.0.12 | 95 | 3/27/2025 |
1.0.11 | 430 | 3/26/2025 |
1.0.10 | 451 | 3/25/2025 |
1.0.9 | 126 | 3/23/2025 |
1.0.8 | 42 | 3/22/2025 |
1.0.7 | 106 | 3/21/2025 |
1.0.6 | 116 | 3/20/2025 |
1.0.5 | 118 | 3/20/2025 |
1.0.4 | 111 | 3/19/2025 |
1.0.3 | 110 | 3/19/2025 |
1.0.2 | 129 | 3/12/2025 |
1.0.1 | 119 | 3/12/2025 |