Recrovit.Extensions.Logging
10.1.0
dotnet add package Recrovit.Extensions.Logging --version 10.1.0
NuGet\Install-Package Recrovit.Extensions.Logging -Version 10.1.0
<PackageReference Include="Recrovit.Extensions.Logging" Version="10.1.0" />
<PackageVersion Include="Recrovit.Extensions.Logging" Version="10.1.0" />
<PackageReference Include="Recrovit.Extensions.Logging" />
paket add Recrovit.Extensions.Logging --version 10.1.0
#r "nuget: Recrovit.Extensions.Logging, 10.1.0"
#:package Recrovit.Extensions.Logging@10.1.0
#addin nuget:?package=Recrovit.Extensions.Logging&version=10.1.0
#tool nuget:?package=Recrovit.Extensions.Logging&version=10.1.0
Recrovit.Extensions.Logging
Overview
Recrovit.Extensions.Logging provides a custom ILoggerProvider implementation named RecroLog for browser-hosted .NET applications. It is designed for Blazor and WebAssembly-style clients that need to capture application logs on the client side and forward them to a server endpoint. The provider can buffer logs in IndexedDB, assign or reuse a client identifier, and transmit logs immediately or in scheduled batches over HTTP. It also supports login-aware delivery, so uploads can wait until the user is authenticated when required. The package is intended for applications that need persistent client telemetry without building a custom logging pipeline from scratch.
What It's For
Use this package when you need client-side logging in a browser-based .NET application and want the logs to survive transient connectivity or delayed delivery.
- Collect logs from standard
Microsoft.Extensions.LoggingAPIs in Blazor or WebAssembly applications. - Buffer log entries locally in IndexedDB before sending them to the server.
- Send logs either immediately as they are written or in timed batches.
- Optionally require an authenticated user before log transmission begins.
How It Works
AddRecroLog(this ILoggingBuilder builder, IConfiguration configuration)registers theRecroLogprovider, binds configuration fromLogging:RecroLog, and wires up the transmitter service.InitializeRecroLogAsync(this IServiceProvider serviceProvider, Func<Task<HttpClient>>? createHttpClient = null, Func<Task<bool>>? isAuthenticated = null)initializes the provider, opens the local IndexedDB store, resolves the client identifier, and starts background transmission when available.RecroLogConfigurationcontrols the endpoint, log filtering, local buffering behavior, upload timing, and whether authentication is required before sending.
Installation
Install the package from NuGet:
dotnet add package Recrovit.Extensions.Logging
Basic Usage
Register the provider during application startup:
using Recrovit.Extensions.Logging;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Logging.AddRecroLog(builder.Configuration);
Configure the provider under Logging:RecroLog:
{
"Logging": {
"RecroLog": {
"ApiEndpoint": "api/logs/ingest",
"ApplicationId": "Sample.Blazor.Client",
"MinLogLevel": "Warning",
"RequireLogin": true,
"MinInterval": 3,
"MaxInterval": 30,
"MaxLogsPerPost": 100,
"ImmediateSendingEnabled": false
}
}
}
Initialize RecroLog after building the host:
using Recrovit.Extensions.Logging;
var host = builder.Build();
await host.Services.InitializeRecroLogAsync();
await host.RunAsync();
If you already have a named HttpClient, configure the provider to use it:
{
"Logging": {
"RecroLog": {
"HttpClientName": "AuthorizedApi",
"ApiEndpoint": "api/logs/ingest",
"ApplicationId": "Sample.Blazor.Client"
}
}
}
builder.Services.AddHttpClient("AuthorizedApi", client =>
{
client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress);
});
builder.Logging.AddRecroLog(builder.Configuration);
If HttpClientName is not provided but ApiEndpoint is set, AddRecroLog(...) creates a named client automatically for the provider using the configured endpoint as the base address.
When you need full control over the sending client or authentication check, pass callbacks to InitializeRecroLogAsync(...):
await host.Services.InitializeRecroLogAsync(
createHttpClient: async () =>
{
var client = new HttpClient
{
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
};
return await Task.FromResult(client);
},
isAuthenticated: async () =>
{
return await Task.FromResult(true);
});
Receiver API Example
The client-side provider posts compressed log payloads to your configured ApiEndpoint. A minimal ASP.NET Core controller action can read the request body, decompress the log entries, and write them through the server logger:
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Recrovit.Abstractions.RecroLog;
[ApiController]
[Route("api/logs")]
public class LogsController : ControllerBase
{
private readonly ILogger<LogsController> _logger;
public LogsController(ILogger<LogsController> logger)
{
_logger = logger;
}
[HttpPost("ingest")]
public async Task<IActionResult> Ingest()
{
try
{
var logValues = await RecroLogDataExtensions.DecompressAsync(Request.Body);
if (logValues?.Length > 0)
{
RecroLogDataExtensions.Log(_logger, logValues);
}
return Ok();
}
catch { }
return BadRequest();
}
}
Adapt this endpoint to your own routing, validation, persistence, or authorization requirements.
Configuration
RecroLogConfiguration supports the following options under Logging:RecroLog:
| Setting | Description |
|---|---|
ApiEndpoint |
Endpoint used for log uploads. When HttpClientName is omitted, this value is also used to configure the provider's named HttpClient base address. |
HttpClientName |
Name of an existing HttpClient registration the provider should use for log transmission. |
ApplicationId |
Logical application identifier stored with each log entry. |
ClientId |
Optional fixed client identifier. If omitted, the provider can generate and persist one locally. |
MinLogLevel |
Lowest LogLevel that should be recorded by the provider. |
RequireLogin |
Delays transmission until the user is authenticated. |
MinInterval |
Delay, in seconds, between batch sends when the queue is actively being drained. |
MaxInterval |
Delay, in seconds, between periodic transmission attempts. |
MaxLogsPerPost |
Maximum number of log entries included in a single upload batch. |
ImmediateSendingEnabled |
Sends logs immediately in addition to local buffering when possible. |
Notes / Limitations
- The package assumes that your application has a server-side HTTP endpoint that accepts the transmitted log payload.
- Local persistence depends on IndexedDB support and is therefore relevant to browser-hosted execution.
- Authentication-aware sending can rely on
AuthenticationStateProvider, or you can provide a customisAuthenticatedcallback during initialization.
Related Packages
Recrovit.RecroGridFramework.Abstraction: shared contracts, models, and abstractions used by the client and server packagesRecrovit.RecroGridFramework.Core: server-side RecroGrid Framework Core implementation and API surfaceRecrovit.RecroGridFramework.Client: client-side API access, framework services, and runtime orchestrationRecrovit.RecroGridFramework.Client.Blazor: Blazor integration built on top of the client servicesRecrovit.RecroGridFramework.Client.Blazor.UI: higher-level UI components built on top of the client services and shared contracts
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.WebAssembly.Authentication (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.0)
- Recrovit.Abstractions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.