CerbiStream 1.0.15
See the version list below for details.
dotnet add package CerbiStream --version 1.0.15
NuGet\Install-Package CerbiStream -Version 1.0.15
<PackageReference Include="CerbiStream" Version="1.0.15" />
<PackageVersion Include="CerbiStream" Version="1.0.15" />
<PackageReference Include="CerbiStream" />
paket add CerbiStream --version 1.0.15
#r "nuget: CerbiStream, 1.0.15"
#addin nuget:?package=CerbiStream&version=1.0.15
#tool nuget:?package=CerbiStream&version=1.0.15
CerbiStream: Dev-Friendly Logging for .NET
π View CerbiStream Benchmarks
Compare against Serilog, NLog, and others. CerbiStream is tuned for performance, governance, and enterprise-scale routing.
β Highlights
- Works with
ILogger<T>
out of the box - Structured logging enforcement via CerbiStream or GovernanceAnalyzer
- Fully supports RabbitMQ, Kafka, Azure Service Bus, AWS SQS/Kinesis, GCP Pub/Sub
- Flexible encryption: None, Base64, AES (configurable)
- Optional Roslyn-based GovernanceAnalyzer or external validator hook
- π Queue-first architecture (sink-agnostic, logs route through CerbIQ if desired)
- Entity Framework and Blazor-friendly via external governance validator option
π External Governance Hook If you're not using the CerbiStream.GovernanceAnalyzer package (e.g., to avoid Roslyn dependency issues with Entity Framework or Blazor), you can provide your own governance validation logic:
options.WithGovernanceValidator((profile, data) =>
{
// Custom governance validation logic
return data.ContainsKey("UserId") && data.ContainsKey("IPAddress");
});
This lets you enforce structure without referencing Roslyn, making CerbiStream fully compatible with EF Core and other analyzers.
β¨ What's New in v1.0.11
- New presets:
BenchmarkMode()
,EnableDeveloperModeWithTelemetry()
- Toggle: telemetry, console, metadata, governance
- JSON conversion with encryption
- Queue routing using enums
π§° Install
dotnet add package CerbiStream
Optional governance analyzer:
dotnet add package CerbiStream.GovernanceAnalyzer
β‘ Quick Start
builder.Logging.AddCerbiStreamWithRouting(options =>
{
options.WithQueue("RabbitMQ", "localhost", "logs-queue")
.EnableDeveloperModeWithoutTelemetry()
.WithEncryptionMode(EncryptionType.Base64);
});
Configuration Setup Guide
CerbiStream is a structured logging framework designed for observability, telemetry enrichment, and governance enforcement. This guide demonstrates how to configure CerbiStreamOptions
using the available setup methods.
π§ Basic Setup
builder.Logging.AddCerbiStream(options =>
{
options.EnableDevModeMinimal(); // Logs only to console, minimal metadata
});
βοΈ Available Preset Modes
β
EnableDevModeMinimal()
Minimal output, console only, no metadata injection, ideal for simple development scenarios.
options.EnableDevModeMinimal();
β
EnableDeveloperModeWithoutTelemetry()
Includes basic metadata injection but skips telemetry logging.
options.EnableDeveloperModeWithoutTelemetry();
β
EnableDeveloperModeWithTelemetry()
Enables metadata injection, console output, and sends to telemetry.
options.EnableDeveloperModeWithTelemetry();
β
EnableBenchmarkMode()
Disables all outputs and features for benchmarking.
options.EnableBenchmarkMode();
π Custom Configuration
Set Custom Queue
options.WithQueue("RabbitMQ", "localhost", "my-logs");
Set Encryption Mode
options.WithEncryptionMode(EncryptionType.Base64);
options.WithEncryptionKey(keyBytes, ivBytes);
Enable or Disable Features
options.WithTelemetryLogging(true);
options.WithConsoleOutput(true);
options.WithMetadataInjection(true);
options.WithTelemetryEnrichment(true);
options.WithGovernanceChecks(true);
options.WithDisableQueue(false);
π§ Add Advanced Metadata
options.WithAdvancedMetadata(true);
options.WithSecurityMetadata(true);
π§ͺ External Governance Validator
options.WithGovernanceValidator((profile, log) =>
{
// Custom validation logic
return log.ContainsKey("requiredKey");
});
π Mode Detection
You can check the runtime mode using:
bool isMinimal = options.IsMinimalMode;
bool isBenchmark = options.IsBenchmarkMode;
π Note: These methods are chainable, allowing fluent configuration:
builder.Logging.AddCerbiStream(options =>
{
options.WithQueue("RabbitMQ", "localhost", "audit-logs")
.WithConsoleOutput(true)
.WithGovernanceChecks(true);
});
πΉ EnableDevModeMinimal()
Purpose: Quickly enables console logging with minimal features for local development or container diagnostics.
- β
Console Output:
true
- β Telemetry Enrichment:
false
- β Metadata Injection:
false
- β Governance Checks:
false
- β Queue Sending:
enabled
- β Best for: Minimal test containers, low-overhead logging in dev
Example:
builder.Logging.AddCerbiStream(options => options.EnableDevModeMinimal());
πΉ EnableDeveloperModeWithoutTelemetry()
Purpose: Enables local developer logging without external telemetry.
- β
Console Output:
true
- β
Metadata Injection:
true
- β Telemetry Enrichment:
false
- β Governance Checks:
false
Example:
builder.Logging.AddCerbiStream(options => options.EnableDeveloperModeWithoutTelemetry());
πΉ EnableDeveloperModeWithTelemetry()
Purpose: Enables all developer logging features including telemetry, for full context during dev work.
- β
Console Output:
true
- β
Metadata Injection:
true
- β
Telemetry Enrichment:
true
- β Governance Checks:
false
Example:
builder.Logging.AddCerbiStream(options => options.EnableDeveloperModeWithTelemetry());
πΉ EnableBenchmarkMode()
Purpose: Disables all overhead logging features, ideal for performance benchmarking.
- β Console Output:
false
- β Metadata Injection:
false
- β Telemetry Enrichment:
false
- β Governance Checks:
false
- β
Queue Sending:
disabled
Example:
builder.Logging.AddCerbiStream(options => options.EnableBenchmarkMode());
π Runtime Encryption
options.WithEncryptionMode(EncryptionType.AES)
.WithEncryptionKey(myKey, myIV);
Default (lazy) test keys:
var (key, iv) = EncryptionHelpers.GetInsecureDefaultKeyPair();
options.WithEncryptionKey(key, iv);
KeyVault example:
var key = Convert.FromBase64String(await secretClient.GetSecret("CerbiKey"));
var iv = Convert.FromBase64String(await secretClient.GetSecret("CerbiIV"));
π οΈ Preset Modes
Method | Description |
---|---|
EnableDeveloperModeWithTelemetry() |
Console + telemetry + metadata |
EnableDeveloperModeWithoutTelemetry() |
Console + metadata, no telemetry |
EnableDevModeMinimal() |
Console only |
EnableBenchmarkMode() |
Silent mode (no telemetry, queue, or console) |
π Retry Example
Policy
.Handle<Exception>()
.WaitAndRetry(3, _ => TimeSpan.FromSeconds(1), (ex, _, attempt, _) =>
{
TelemetryContext.IsRetry = true;
TelemetryContext.RetryAttempt = attempt;
});
π§ Configuration Options
Option | Description |
---|---|
.WithQueue(...) |
Configure queue host, name, and type |
.DisableQueue() |
Stops sending logs to queues |
.WithTelemetryProvider() |
Set custom telemetry provider |
.IncludeSecurityMetadata() |
Adds IP/UserID info |
.EnableTelemetryLogging() |
Sends to telemetry even if queue is disabled |
π Telemetry Provider Support
Provider | Supported |
---|---|
OpenTelemetry | β |
Azure App Insights | β |
AWS CloudWatch | β |
GCP Trace | β |
Datadog | β |
π Code Samples
CerbiLoggerBuilder
var logger = new CerbiLoggerBuilder()
.UseAzureServiceBus("<conn>", "<queue>")
.EnableDebugMode()
.Build(logger, new ConvertToJson(), new NoOpEncryption());
Fluent API
var options = new CerbiStreamOptions()
.WithEncryptionMode(EncryptionType.Base64)
.WithQueue("RabbitMQ", "localhost", "logs");
AddCerbiStreamWithRouting (DI)
builder.Logging.AddCerbiStreamWithRouting(options =>
{
options.WithQueue("AzureServiceBus", "sb://...", "queue")
.WithEncryptionMode(EncryptionType.AES);
});
π§ͺ Unit Test Example
var mockQueue = Substitute.For<IQueue>();
var logger = new Logging(Substitute.For<ILogger<Logging>>(), mockQueue, new ConvertToJson(), new NoOpEncryption());
var result = await logger.LogEventAsync("Test", LogLevel.Information);
Assert.True(result);
π Supported Queues
- RabbitMQ
- Kafka
- Azure Queue / Service Bus
- AWS SQS / Kinesis
- Google Pub/Sub
π§΅ Queue-First Logging (Sink-Agnostic)
CerbiStream does not directly send logs to sinks like Splunk, Elastic, or Blob.
Instead:
- π Logs are emitted to queues only (Kafka, RabbitMQ, Azure, etc.)
- π§ CerbIQ reads from these queues and sends logs to sinks
- β Keeps log generation decoupled from log delivery
This design gives you:
- Better performance
- Retry-friendly resilience
- Pluggable downstream integrations
β‘οΈ Add CerbIQ to handle routing and sink delivery.
π Governance Enforcement (Optional)
{
"LoggingProfiles": {
"SecurityLog": {
"RequiredFields": ["UserId", "IPAddress"],
"OptionalFields": ["DeviceType"]
}
}
}
π License
MIT
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.5)
- AWSSDK.Kinesis (>= 3.7.402.86)
- AWSSDK.SQS (>= 3.7.400.109)
- Azure.Core (>= 1.45.0)
- Azure.Messaging.ServiceBus (>= 7.18.4)
- Azure.Storage.Common (>= 12.23.0-beta.1)
- Azure.Storage.Queues (>= 12.22.0-beta.1)
- cerberus-logger-interface (>= 1.0.26)
- Datadog.Trace (>= 3.12.0)
- Google.Cloud.Logging.V2 (>= 4.4.0)
- Google.Cloud.PubSub.V1 (>= 3.21.0)
- Google.Protobuf (>= 3.30.0)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.Extensions.Configuration (>= 9.0.2)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0-preview.1.25080.5)
- Moq (>= 4.20.72)
- NUnit (>= 4.3.2)
- OpenTelemetry (>= 1.11.2)
- OpenTelemetry.Exporter.Console (>= 1.11.2)
- RabbitMQ.Client (>= 6.4.0)
- System.Configuration.ConfigurationManager (>= 10.0.0-preview.1.25080.5)
- System.Data.SqlClient (>= 4.9.0)
- System.Diagnostics.EventLog (>= 10.0.0-preview.1.25080.5)
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 | 165 | 4/13/2025 |
1.1.0 | 163 | 4/13/2025 |
1.0.16 | 128 | 4/10/2025 |
1.0.15 | 126 | 4/7/2025 |
1.0.14 | 78 | 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 |