BiaLog 2.0.2
BiaLog
Enterprise-grade centralized logging for .NET 9 applications.
BiaLog is distributed as a single NuGet package. Install one package, call AddBiaLog(...), and use UseBiaLog() in the pipeline. The internal projects in this repository remain implementation modules and are bundled into the public package.
Install
dotnet add package BiaLog
The BiaLog package carries the runtime dependencies required by the current implementation graph, including:
- SQL Server
- PostgreSQL
- MySQL
- SQLite
- Oracle
- MongoDB
- OpenTelemetry
- Serilog
- NLog
- Elasticsearch
Consumers should not need to manually chase provider packages for the supported runtime surface.
Quick Start
Configuration-first setup
using BiaLog;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddBiaLog(builder.Configuration);
var app = builder.Build();
app.UseBiaLog();
app.MapHealthChecks("/health");
app.Run();
Example appsettings.json:
{
"ConnectionStrings": {
"DefaultConnectionString": "Server=localhost;Database=AppDb;Trusted_Connection=true;TrustServerCertificate=true;"
},
"BiaLog": {
"Provider": "SqlServer",
"DatabaseName": "BiaLog",
"ApplicationName": "MyApp",
"Environment": "Production",
"DefaultTenantId": "default",
"EnableRequestLogging": true,
"EnableResponseLogging": false,
"EnableAsyncQueue": true,
"EnableRetentionService": true,
"EnableAlertService": false,
"EnableElastic": false,
"EnableOpenTelemetry": false
}
}
AddBiaLog(builder.Configuration) binds the BiaLog section and falls back to ConnectionStrings:DefaultConnectionString when BiaLog:ConnectionString is not set.
Advanced setup
using BiaLog;
using BiaLog.Core.Enums;
builder.Services.AddBiaLog(options =>
{
options.Provider = LogProvider.PostgreSql;
options.ConnectionString = builder.Configuration.GetConnectionString("DefaultConnectionString")!;
options.DatabaseName = "BiaLog";
options.ApplicationName = "MyApp";
options.Environment = builder.Environment.EnvironmentName;
options.DefaultTenantId = "tenant-a";
options.EnableRequestLogging = true;
options.EnableResponseLogging = false;
options.EnableAsyncQueue = true;
options.EnableRetentionService = true;
});
Usage
Inject ILoggerService anywhere in your app:
using BiaLog.Core.Interfaces;
public sealed class MyService
{
private readonly ILoggerService _logger;
public MyService(ILoggerService logger)
{
_logger = logger;
}
public async Task DoWorkAsync()
{
await _logger.LogInfoAsync(
"Operation started",
tenantId: "tenant-a",
extra: new Dictionary<string, object> { ["orderId"] = 123 },
tags: ["orders", "processing"]);
}
}
Supported Providers
Set BiaLogOptions.Provider or BiaLog:Provider to one of:
SqlServerPostgreSqlMySqlSqliteOracleMongoDB
Solution Layout
BiaLog.slnx
├── src/BiaLog.Package # Public package entry point
├── src/BiaLog.Core # Models, interfaces, options, enums
├── src/BiaLog.Providers # EF Core + MongoDB provider implementations
├── src/BiaLog.Middleware # HTTP pipeline middleware
├── src/BiaLog.Services # Core services
├── src/BiaLog.BackgroundServices # Hosted services
├── src/BiaLog.Integrations # Elastic, Serilog, NLog, OpenTelemetry, health checks
├── src/BiaLog.Api # API application
├── src/BiaLog.Dashboard # Dashboard application
├── samples/BiaLog.Sample # Minimal sample app
└── tests/BiaLog.Tests # Test project
Build, Test, Pack
dotnet restore BiaLog.slnx
dotnet build BiaLog.slnx
dotnet test BiaLog.slnx
dotnet pack src/BiaLog.Package/BiaLog.Package.csproj -c Release -o ./artifacts/packages
The produced package is BiaLog.
Local Package Validation
To validate the single-package consumer flow against a local build:
dotnet pack src/BiaLog.Package/BiaLog.Package.csproj -c Release -o ./artifacts/packages
dotnet new web -n BiaLog.Consumer -o /tmp/BiaLog.Consumer --framework net9.0
dotnet add /tmp/BiaLog.Consumer/BiaLog.Consumer.csproj package BiaLog --source ./artifacts/packages
Then update /tmp/BiaLog.Consumer/Program.cs to call builder.Services.AddBiaLog(builder.Configuration); and app.UseBiaLog();, add a BiaLog section to appsettings.json, and run:
dotnet build /tmp/BiaLog.Consumer/BiaLog.Consumer.csproj
You can inspect transitive restore results with:
dotnet list /tmp/BiaLog.Consumer/BiaLog.Consumer.csproj package --include-transitive
This should show provider dependencies such as Oracle.EntityFrameworkCore coming from the single BiaLog package.
License
Proprietary - Bia Yazilim
Showing the top 20 packages that depend on BiaLog.
| Packages | Downloads |
|---|---|
|
Bia.Log
Package Description
|
1 |
|
BiaLog.Dashboard
Reusable Razor Pages dashboard package for BiaLog. Includes UI pages, static assets and Bia.Auth integration on top of the BiaLog package.
|
1 |
|
BiaLog.Api
Reusable ASP.NET Core API package for BiaLog. Includes controllers, SignalR hub, OpenAPI wiring and Bia.Auth integration on top of the BiaLog package.
|
1 |
|
BiaLog.Api
Reusable ASP.NET Core API package for BiaLog. Includes controllers, SignalR hub, OpenAPI wiring and Bia.Auth integration on top of the BiaLog package.
|
0 |
|
BiaLog.Dashboard
Reusable Razor Pages dashboard package for BiaLog. Includes UI pages, static assets and Bia.Auth integration on top of the BiaLog package.
|
0 |
.NET 9.0
- Elastic.Clients.Elasticsearch (>= 8.17.3)
- Microsoft.Data.SqlClient (>= 6.0.1)
- Microsoft.EntityFrameworkCore (>= 9.0.6)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.6)
- Microsoft.EntityFrameworkCore.Sqlite (>= 9.0.6)
- MongoDB.Driver (>= 3.4.0)
- NLog (>= 5.4.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- OpenTelemetry (>= 1.12.0)
- OpenTelemetry.Api (>= 1.12.0)
- Oracle.EntityFrameworkCore (>= 9.23.80)
- Pomelo.EntityFrameworkCore.MySql (>= 9.0.0)
- Serilog (>= 4.2.0)
- Serilog.Sinks.PeriodicBatching (>= 5.0.0)