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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Recrovit.Extensions.Logging" Version="10.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Recrovit.Extensions.Logging" Version="10.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Recrovit.Extensions.Logging" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Recrovit.Extensions.Logging --version 10.1.0
                    
#r "nuget: Recrovit.Extensions.Logging, 10.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Recrovit.Extensions.Logging@10.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Recrovit.Extensions.Logging&version=10.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Recrovit.Extensions.Logging&version=10.1.0
                    
Install as a Cake Tool

Recrovit.Extensions.Logging

NuGet Version

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.Logging APIs 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 the RecroLog provider, binds configuration from Logging: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.
  • RecroLogConfiguration controls 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 custom isAuthenticated callback during initialization.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
10.1.0 48 7/17/2026
10.0.0 141 1/26/2026
8.0.0 213 12/16/2024