Serilog Sink Integration
Send structured logs from .NET applications directly to Radianz
Overview
What is the Serilog Sink?
The Serilog.Sinks.Radianz NuGet package is a Serilog sink that sends structured log events directly to the Radianz platform. Logs are batched and sent asynchronously with retry and exponential backoff — zero impact on your application's performance. Supports both HTTP and Azure Service Bus transports.
How it works
Installation
Install the NuGet package from nuget.org
Step 1 — Install the package
Add the Serilog.Sinks.Radianz NuGet package to your project:
dotnet add package Serilog.Sinks.RadianzConfiguration
Configure the sink with your Radianz credentials
Quick Start
Run this example in a console application to send one fictional error. Replace clientId and apiKey with credentials from the same Radianz instance as baseUrl. The default is https://radianz.io; for an authorized QA account, use https://radianzqa.pgms.dev. Never send production credentials to a test instance.
using Serilog;
using Serilog.Sinks.Radianz.Extensions;
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Environment", "Development")
.WriteTo.RadianzHttp(
clientId: "your-client-id",
apiKey: "your-api-key",
baseUrl: "https://radianz.io")
.CreateLogger();
try
{
throw new InvalidOperationException("Radianz setup test — fictional error");
}
catch (InvalidOperationException error)
{
Log.Error(error, "Radianz setup test for {AppName}", "MyApp");
}
finally
{
await Log.CloseAndFlushAsync();
}ASP.NET Core Integration
For ASP.NET Core applications, use the host builder integration to read credentials from configuration:
builder.Host.UseSerilog((ctx, lc) => lc
.WriteTo.RadianzHttp(
clientId: ctx.Configuration["Radianz:ClientId"],
apiKey: ctx.Configuration["Radianz:ApiKey"])
.WriteTo.Console());clientId and its API token as apiKey. Keep these credentials out of source control.Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
clientId | string | — | Client ID for authentication (required) |
apiKey | string | — | API key for authentication (required) |
baseUrl | string | https://radianz.io | Base URL of the Radianz instance |
restrictedToMinimumLevel | LogEventLevel | Verbose | Minimum log level to send |
batchSizeLimit | int | 50 | Maximum number of events per batch |
batchPeriod | TimeSpan | 5s | Maximum time before flushing the batch |
queueLimit | int | 10000 | Maximum number of events to queue before dropping |
Advanced Configuration
Fine-tune batching, retry, and transport options
Custom Batching & Minimum Level
Adjust batch size, period, and minimum log level to control volume and frequency:
.WriteTo.RadianzHttp(
clientId: "your-client-id",
apiKey: "your-api-key",
restrictedToMinimumLevel: LogEventLevel.Warning,
batchSizeLimit: 100,
batchPeriod: TimeSpan.FromSeconds(10))Full Options via Action
For complete control over all settings, use the action-based configuration:
.WriteTo.Radianz(options =>
{
options.TransportType = RadianzTransportType.Http;
options.HttpOptions = new HttpTransportOptions
{
ClientId = "your-client-id",
ApiKey = "your-api-key"
};
options.Batching.BatchSizeLimit = 100;
options.Retry.MaxRetryAttempts = 5;
})Azure Service Bus Transport
Instead of sending logs directly over HTTP, you can route them through Azure Service Bus for higher reliability:
.WriteTo.RadianzMessageQueue(
connectionString: "Endpoint=sb://your-ns.servicebus.windows.net/;...",
queueName: "radianz-logs")