LogBug.Client.AspNetCore 0.1.1

dotnet add package LogBug.Client.AspNetCore --version 0.1.1
                    
NuGet\Install-Package LogBug.Client.AspNetCore -Version 0.1.1
                    
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="LogBug.Client.AspNetCore" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LogBug.Client.AspNetCore" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="LogBug.Client.AspNetCore" />
                    
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 LogBug.Client.AspNetCore --version 0.1.1
                    
#r "nuget: LogBug.Client.AspNetCore, 0.1.1"
                    
#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 LogBug.Client.AspNetCore@0.1.1
                    
#: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=LogBug.Client.AspNetCore&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=LogBug.Client.AspNetCore&version=0.1.1
                    
Install as a Cake Tool

LogBug.Client

Official .NET SDK for LogBug.ai. Two packages:

  • LogBug.Client — core client, DI registration, and an ILoggerProvider that forwards Microsoft.Extensions.Logging entries to LogBug.
  • LogBug.Client.AspNetCore — middleware that reports unhandled exceptions from the ASP.NET Core request pipeline.

Installation

dotnet add package LogBug.Client
dotnet add package LogBug.Client.AspNetCore # optional, for ASP.NET Core apps

Usage

  1. Create an application in the LogBug.ai dashboard and copy its API key (lb_live_...).
  2. Add a LogBug section to appsettings.json:
{
  "LogBug": {
    "ApiKey": "lb_live_...",
    "Environment": "Production"
  }
}
  1. Register LogBug during startup with a single call. This wires up ILogBugClient, its HttpClient, and an ILoggerProvider that forwards Microsoft.Extensions.Logging entries (including unhandled exceptions logged anywhere in the app) to LogBug.ai — no extra setup required:
builder.Services.AddLogBug(builder.Configuration);

To set or override options from code (e.g. for values that shouldn't live in appsettings.json), pass a configure delegate. It runs after binding from configuration:

builder.Services.AddLogBug(builder.Configuration, options =>
{
    options.Environment = builder.Environment.EnvironmentName;
});

If you'd rather configure everything in code and skip configuration binding, AddLogBugClient is still available:

builder.Services.AddLogBugClient(options =>
{
    options.ApiKey = builder.Configuration["LogBug:ApiKey"]!;
    options.Environment = builder.Environment.EnvironmentName;
});

Capturing exceptions and messages manually

public class CheckoutService(ILogBugClient logBug)
{
    public async Task ChargeAsync(Order order)
    {
        try
        {
            await _paymentProvider.ChargeAsync(order);
        }
        catch (Exception ex)
        {
            await logBug.CaptureExceptionAsync(ex, metadata: new Dictionary<string, object?>
            {
                ["orderId"] = order.Id,
            });
            throw;
        }
    }
}
await logBug.CaptureMessageAsync("Payment provider responded slowly", LogBugSeverity.Warning);

Microsoft.Extensions.Logging integration

AddLogBug(builder.Configuration) already registers an ILoggerProvider that turns LogBug into a sink for everything logged via ILogger — including logger.LogError(ex, ...) calls anywhere in your app. (If you used AddLogBugClient instead, add the provider explicitly with builder.Logging.AddLogBug();.)

Which entries get forwarded is controlled by the standard Logging configuration in appsettings.json. By default, Logging:LogLevel:Default applies to LogBug like any other provider. To forward only warnings and above to LogBug without affecting your other providers (e.g. console), scope it using the LogBug provider alias:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    },
    "LogBug": {
      "LogLevel": {
        "Default": "Warning"
      }
    }
  }
}

ASP.NET Core middleware

Automatically report unhandled exceptions from the request pipeline:

app.UseLogBug();

Place UseLogBug() early in the pipeline (before UseExceptionHandler or UseRouting) so it observes exceptions from all downstream middleware and endpoints. The exception is reported and then re-thrown, so your existing exception handling continues to run unchanged.

Configuration reference

Option Type Default Description
ApiKey string required API key for the target application.
ApiUrl string https://api.logbug.ai Override for self-hosted deployments.
Environment string Production Reported with every event.
DefaultMetadata IDictionary<string, object?> null Merged into every event's metadata.

All of these can be set via the LogBug section of appsettings.json when using AddLogBug. For example, to point at a self-hosted LogBug API:

{
  "LogBug": {
    "ApiKey": "lb_live_...",
    "ApiUrl": "https://logbug.internal.example.com",
    "Environment": "Staging"
  }
}

Severity levels

Info, Warning, Error, Critical — serialized as lowercase strings to match the LogBug API contract.

License

MIT

Product 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.  net10.0 was computed.  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
0.1.1 140 6/15/2026
0.1.0 118 6/15/2026