CerbiStream 1.0.9
See the version list below for details.
dotnet add package CerbiStream --version 1.0.9
NuGet\Install-Package CerbiStream -Version 1.0.9
<PackageReference Include="CerbiStream" Version="1.0.9" />
<PackageVersion Include="CerbiStream" Version="1.0.9" />
<PackageReference Include="CerbiStream" />
paket add CerbiStream --version 1.0.9
#r "nuget: CerbiStream, 1.0.9"
#addin nuget:?package=CerbiStream&version=1.0.9
#tool nuget:?package=CerbiStream&version=1.0.9
CerbiStream Logging Library
CerbiStream is a next-generation logging solution built for structured logs, governance enforcement, and multi-destination routing. It ensures secure, consistent, and high-performance logging for cloud, on-prem, and hybrid environments.
π What's New?
- Readme Update only
Updates included from previous version:
- Telemetry Context Enrichment β Automatically include metadata like
ServiceName
,OriginApp
,UserType
,Feature
,IsRetry
, andRetryAttempt
. - Static Enrichment β All telemetry context fields are set once and injected into logs automatically.
- Retry Metadata β Integrated with Polly and middleware to track retries at the log level.
- Telemetry Support β Seamless integration with AWS CloudWatch, GCP Cloud Trace, Azure Application Insights, and Datadog.
- Configurable Telemetry Providers β Easily plug in multiple providers.
- Optimized Telemetry β Exclude noisy events (e.g.,
DebugLog
,HealthCheck
) and enable sampling for cost control.
π§° Getting Started
CerbiStream works out-of-the-box. Install, configure, and start logging:
- Install the NuGet package
- Set your queue and enrichment metadata
- Start logging with
ILogger<T>
β For governance enforcement, install the GovernanceAnalyzer.
π§ High-Level Architecture
CerbiStream is designed to separate concerns between:
- β Logging (CerbiStream)
- β Governance (GovernanceAnalyzer)
- β Telemetry Routing (via optional config or CerbIQ (coming soon))
π¦ Installation
Install CerbiStream from NuGet:
dotnet add package CerbiStream
If you want Governance Enforcement, also install:
dotnet add package CerbiStream.GovernanceAnalyzer
β‘ Quick Start (Minimal Setup) With CerbiStream, you can integrate logging in seconds.
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using CerbiStream.Logging.Extensions;
```csharp
class Program
{
static void Main()
{
var serviceProvider = new ServiceCollection()
.AddLogging(builder =>
{
builder.AddConsole();
builder.AddCerbiStream(options =>
{
options.SetQueue("RabbitMQ", "localhost", "logs-queue");
options.EnableDevMode();
options.EnableGovernance();
// Set once, reused for all logs
TelemetryContext.ServiceName = "CheckoutService";
TelemetryContext.OriginApp = "MyFrontendApp";
TelemetryContext.UserType = "InternalUser"; // System | ApiConsumer | Guest
});
})
.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
logger.LogInformation("App started");
}
}
π οΈ Advanced Configuration
If you need more control, you can configure CerbiStream dynamically.
var config = new CerbiStreamOptions();
config.SetQueue("Kafka", "kafka://broker-url", "app-logs");
config.DisableDevMode();
config.EnableGovernance();
config.IncludeAdvancedMetadata();
var logger = new CerbiStreamLogger(config);
π Supported Logging Destinations
Queue Type | Example Usage |
---|---|
RabbitMQ | QueueType = "RabbitMQ" |
Kafka | QueueType = "Kafka" |
Azure Queue Storage | QueueType = "AzureQueue" |
Azure Service Bus | QueueType = "AzureServiceBus" |
AWS SQS | QueueType = "AWS_SQS" |
AWS Kinesis | QueueType = "AWS_Kinesis" |
Google Pub/Sub | QueueType = "GooglePubSub" |
π Automatic Metadata (No Setup Required)
Metadata Field | Auto-Detected? | Example Value |
---|---|---|
CloudProvider | β Yes | AWS, Azure, GCP, On-Prem |
Region | β Yes | us-east-1, eu-west-2 |
Environment | β Yes | Development, Production |
ApplicationVersion | β Yes | v1.2.3 |
RequestId | β Yes (Generated) | abc123 |
TransactionType | β Developer Sets | REST, gRPC, Kafka |
TransactionStatus | β Developer Sets | Success, Failed |
β Telemetry Context Fields (Auto-Enriched)
- Field Description
- ServiceName - Logical name of the service
- OriginApp - Source app triggering the log
- UserType - System, ApiConsumer, etc.
- Feature - Business context like Checkout
- IsRetry - true if retrying the operation
- RetryAttempt - Number of retry attempts
𧩠Feature & Business Area Enum
Use a shared enum for consistency:
Always show details
Copy
public enum FeatureArea
{
Checkout,
Login,
Search,
DataExport,
Onboarding
}
Set it before logging:
TelemetryContext.Feature = FeatureArea.Checkout.ToString();
logger.LogInformation("Item added to cart");
π Retry Metadata (e.g., Polly Integration)
Policy
.Handle<Exception>()
.WaitAndRetry(3, _ => TimeSpan.FromSeconds(1), (ex, _, attempt, _) =>
{
TelemetryContext.IsRetry = true;
TelemetryContext.RetryAttempt = attempt;
});
π Governance & Structured Logging
Governance allows organizations to enforce structured logging signatures by:
- β
Defining required fields (e.g., every log must include
UserId
,RequestId
, etc.). - β Allowing optional fields that developers can extend dynamically.
- β
Using a governance configuration file (
cerbi_governance.json
) for dynamic updates. Example Governance JSON:
{
"LoggingProfiles": {
"TransactionLog": {
"RequiredFields": ["TransactionId", "UserId", "Amount"],
"OptionalFields": ["DiscountCode"]
},
"SecurityLog": {
"RequiredFields": ["UserId", "IPAddress"],
"OptionalFields": ["DeviceType"]
}
}
}
If GovernanceEnabled = true, logs must match the configured structure.
β Governance Analyzer (Build-Time Validation)
CerbiStream GovernanceAnalyzer uses Roslyn to validate log compliance at build time. This ensures structured logs without runtime overhead.
π Debug Mode (Local Development) CerbiStream prevents queue logging while debugging. This is enabled by default (EnableDevMode = true).
var config = new CerbiStreamOptions();
config.EnableDevMode();
var logger = new CerbiStreamLogger(config);
await logger.LogEventAsync("Debugging locally", LogLevel.Debug);
π Meta Data Sharing (Opt-In)
CerbiStream collects aggregate trends across applications for AI-powered insights. β No Personally Identifiable Information (PII) is stored.
If enabled, your logs contribute to global analytics (Error Trends, Cloud Performance, API Response Issues). If disabled, your logs remain 100% private.
var config = new CerbiStreamOptions();
config.IncludeAdvancedMetadata();
config.IncludeSecurityMetadata();
π Telemetry Support (Optional)
CerbiStream now supports distributed tracing and application performance monitoring through multiple telemetry providers.
Supported Telemetry Providers
Provider | Status |
---|---|
Azure Application Insights | β Supported |
AWS CloudWatch | β Supported |
Google Cloud Trace | β Supported |
Datadog | β Supported |
OpenTelemetry (default) | β Supported |
π Configuring Telemetry in CerbiStream
To enable telemetry, specify a provider in the CerbiStreamOptions
configuration:
var config = new CerbiStreamOptions();
config.SetTelemetryProvider(new AppInsightsTelemetryProvider()); // Choose from AppInsights, AWS, GCP, Datadog, etc.
config.SetQueue("RabbitMQ", "localhost", "logs-queue");
config.EnableGovernance();
var logger = new CerbiStreamLogger(config);
π Multi-Cloud Telemetry Routing
You can route different types of logs to different telemetry providers for better visibility.
Log Type | Default Destination |
---|---|
Application Logs | Google Cloud Trace |
Infrastructure Logs | AWS CloudWatch |
Security & Audit Logs | Azure Application Insights |
Performance Metrics | Datadog |
To customize this, configure the routing rules in your governance JSON file:
{
"TelemetryRouting": {
"ApplicationLogs": "GoogleCloud",
"InfraLogs": "AWS",
"SecurityLogs": "Azure",
"PerformanceMetrics": "Datadog"
}
}
β‘ Optimized Telemetry Collection
CerbiStream minimizes unnecessary logging noise while ensuring critical events are captured.
- β Event Sampling β Configurable rate limiting to balance cost & observability.
- β
Noise Reduction β Filters out low-priority logs like
HealthCheck
&DebugLog
. - β Auto-Enabled for Supported Providers β Telemetry is automatically enabled when a supported provider is detected (AWS, GCP, Azure).
π Auto-Enabled Telemetry Providers
CerbiStream detects and configures telemetry based on your cloud environment.
Cloud Provider | Auto-Enabled Telemetry Service |
---|---|
AWS | CloudWatch |
Azure | Application Insights |
Google Cloud | Stackdriver Trace |
On-Prem | OpenTelemetry (Custom Configuration) |
Developers can override these settings to manually specify their preferred telemetry provider.
π Multi-Telemetry Provider Setup
CerbiStream allows you to integrate multiple telemetry providers for better observability across cloud environments.
π Example: Using OptimizedTelemetryProvider, AWS CloudWatch & Azure Application Insights
using CerbiStream.Configuration;
using CerbiStream.Interfaces;
using CerbiStream.Classes.OpenTelemetry;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
class Program
{
static void Main()
{
var serviceProvider = new ServiceCollection()
.AddLogging(builder =>
{
builder.AddConsole();
builder.AddCerbiStream(options =>
{
options.SetQueue("RabbitMQ", "localhost", "logs-queue");
options.EnableDevMode();
options.EnableGovernance();
// β
Optimized telemetry provider (efficient tracing with sampling)
options.AddTelemetryProvider(new OptimizedTelemetryProvider(samplingRate: 0.5));
// β
Add multiple telemetry providers
options.AddTelemetryProvider(new CloudWatchTelemetryProvider());
options.AddTelemetryProvider(new AppInsightsTelemetryProvider());
});
})
.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
logger.LogInformation("Application started successfully!");
logger.LogError("Critical error detected in system.");
}
}
You can enable, disable, or prioritize telemetry providers as needed.
options.EnableTelemetry(); // Enable all auto-detected telemetry providers
options.DisableTelemetry(); // Disable all telemetry tracking
options.SetTelemetrySamplingRate(0.3); // 30% sampling for cost optimization
Example: Using OptimizedTelemetryProvider
options.AddTelemetryProvider(new OptimizedTelemetryProvider(samplingRate: 0.5));
π Rollup & Multi-Project Visibility
CerbiStream supports centralized telemetry aggregation, allowing you to visualize logs, metrics, and traces from multiple services or microservices in one place.
This is especially useful for:
- π Microservices Architectures
- 𧩠Distributed Systems
- π οΈ Multi-Environment Monitoring (Dev / QA / Prod)
π§ Example: Using Application Insights for Rollups
With Azure Application Insights, all telemetry (from different apps) can be grouped under a single Application Map:
options.AddTelemetryProvider(new AppInsightsTelemetryProvider());
Be sure to:
Use the same Instrumentation Key or Connection String across services. Tag logs with AppName, Environment, or Component for grouping:
var metadata = new Dictionary<string, string>
{
{ "AppName", "CheckoutService" },
{ "Environment", "Production" },
{ "Component", "PaymentProcessor" }
};
logger.LogEvent("Payment failed", LogLevel.Error, metadata);
π§ Global Observability (Optional) (coming soon)
With IncludeAdvancedMetadata(), your logs can contribute (without PII) to:
Industry-wide error trends
ML-driven root cause patterns
Performance benchmarking across cloud platforms
config.IncludeAdvancedMetadata();
π₯ Why Use CerbiStream?
- β
Structured Logs by Default β Consistent schema with contextual metadata like
Feature
,ServiceName
, andRetryAttempt
. - β Multi-Cloud Ready β Route telemetry to Azure, AWS, GCP, Datadog, or OpenTelemetry.
- β NPI-Free Insights β Built from the ground up to exclude personally identifiable information.
- β
Business-Aware Logging β Capture
UserType
,OriginApp
, andFeatureArea
for analytics and ML without leaking sensitive data. - β Central Rollups Across Microservices β Logs can be grouped by service, app, or feature to enable intelligent visualization and trend detection.
- β No External Dependencies β Just install & start logging.
- π Optimized Performance β Uses static enrichment and telemetry sampling to reduce overhead.
- π Security First β Optional field-level encryption and governance enforcement.
- π Global Insights β Enables anonymized, cross-client trend discovery (if opted-in).
- β‘ Minimal Setup β Works out-of-the-box with simple constructor injection.
π License CerbiStream is open-source and available under the MIT License.
π£ Want to contribute?
Star the repo β, open an issue π, or suggest a feature π§ !
π§βπ» 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)
- CerbiStream.GovernanceAnalyzer (>= 1.0.1)
- 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.0.15 | 0 | 4/7/2025 |
1.0.14 | 37 | 4/6/2025 |
1.0.13 | 97 | 3/28/2025 |
1.0.12 | 92 | 3/27/2025 |
1.0.11 | 427 | 3/26/2025 |
1.0.10 | 450 | 3/25/2025 |
1.0.9 | 122 | 3/23/2025 |
1.0.8 | 39 | 3/22/2025 |
1.0.7 | 102 | 3/21/2025 |
1.0.6 | 112 | 3/20/2025 |
1.0.5 | 118 | 3/20/2025 |
1.0.4 | 110 | 3/19/2025 |
1.0.3 | 110 | 3/19/2025 |
1.0.2 | 129 | 3/12/2025 |
1.0.1 | 119 | 3/12/2025 |