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
<PackageReference Include="LogBug.Client.AspNetCore" Version="0.1.1" />
<PackageVersion Include="LogBug.Client.AspNetCore" Version="0.1.1" />
<PackageReference Include="LogBug.Client.AspNetCore" />
paket add LogBug.Client.AspNetCore --version 0.1.1
#r "nuget: LogBug.Client.AspNetCore, 0.1.1"
#:package LogBug.Client.AspNetCore@0.1.1
#addin nuget:?package=LogBug.Client.AspNetCore&version=0.1.1
#tool nuget:?package=LogBug.Client.AspNetCore&version=0.1.1
LogBug.Client
Official .NET SDK for LogBug.ai. Two packages:
LogBug.Client— core client, DI registration, and anILoggerProviderthat forwardsMicrosoft.Extensions.Loggingentries 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
- Create an application in the LogBug.ai dashboard and copy its API key
(
lb_live_...). - Add a
LogBugsection toappsettings.json:
{
"LogBug": {
"ApiKey": "lb_live_...",
"Environment": "Production"
}
}
- Register LogBug during startup with a single call. This wires up
ILogBugClient, itsHttpClient, and anILoggerProviderthat forwardsMicrosoft.Extensions.Loggingentries (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 | Versions 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. |
-
net8.0
- LogBug.Client (>= 0.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.