LogMaster.NetCore 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LogMaster.NetCore --version 0.1.0
                    
NuGet\Install-Package LogMaster.NetCore -Version 0.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="LogMaster.NetCore" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LogMaster.NetCore" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="LogMaster.NetCore" />
                    
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 LogMaster.NetCore --version 0.1.0
                    
#r "nuget: LogMaster.NetCore, 0.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 LogMaster.NetCore@0.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=LogMaster.NetCore&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=LogMaster.NetCore&version=0.1.0
                    
Install as a Cake Tool

LogMaster

LogMaster is a small ASP.NET Core helper for detailed HTTP request/response logging that can be turned on and off from an admin panel through a database-backed setting.

It is designed for temporary troubleshooting. Keep detailed body logging disabled by default in production, then enable it for a short time when you need to inspect payloads.

What it gives you

  • Global middleware; no logging code inside controllers or services.
  • Runtime on/off switch stored in DB.
  • Selectable log targets: ILogger/Serilog, DB table, or both.
  • Admin API for reading/updating detailed logging settings.
  • Request body, response body, headers, query string, status code, duration, user, trace id.
  • Sensitive field masking for headers and JSON bodies.
  • Path exclusions such as /health, /swagger, /metrics.
  • Max body length limit.

Install

After publishing to NuGet:

dotnet add package LogMaster.NetCore

For local testing before publishing:

dotnet pack .\LogMaster\LogMaster.csproj -c Release
dotnet add package LogMaster.NetCore --source .\artifacts\packages

Use in an ASP.NET Core app

Wire it in Program.cs.

using LogMaster.DependencyInjection;
using Microsoft.Data.SqlClient;

builder.Services.AddLogMaster(options =>
{
    options.AdminRoute = "/admin/logging/detailed";
    options.AuthorizationPolicy = "AdminOnly";
    options.SettingsCacheDuration = TimeSpan.FromSeconds(5);
});

builder.Services.AddLogMasterDbSettingsStore(
    async (_, cancellationToken) =>
    {
        var connection = new SqlConnection(
            builder.Configuration.GetConnectionString("DefaultConnection"));

        await connection.OpenAsync(cancellationToken);
        return connection;
    });

// Default detailed HTTP logs go to ILogger, so Serilog receives them automatically.
// To write detailed HTTP logs directly to a DB table instead, add:
builder.Services.AddLogMasterDbLogSink(
    async (_, cancellationToken) =>
    {
        var connection = new SqlConnection(
            builder.Configuration.GetConnectionString("DefaultConnection"));

        await connection.OpenAsync(cancellationToken);
        return connection;
    });

var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();

app.UseLogMasterDetailedLogging();

app.MapControllers();
app.MapLogMasterAdminApi();

app.Run();

The default store creates this SQL Server table automatically:

CREATE TABLE [dbo].[LogMasterSettings]
(
    [Key] nvarchar(200) NOT NULL PRIMARY KEY,
    [Value] nvarchar(max) NOT NULL,
    [UpdatedAtUtc] datetime2(7) NOT NULL
);

Log targets

By default, detailed HTTP logs are written through ILogger.

That means if your app uses Serilog, LogMaster logs flow to your existing Serilog sinks automatically:

builder.Services.AddLogMaster();

Use a DB table instead of ILogger:

builder.Services.AddLogMaster();

builder.Services.AddLogMasterDbLogSink(
    async (_, cancellationToken) =>
    {
        var connection = new SqlConnection(
            builder.Configuration.GetConnectionString("DefaultConnection"));

        await connection.OpenAsync(cancellationToken);
        return connection;
    });

Use both DB and ILogger/Serilog:

builder.Services.AddLogMaster();

builder.Services.AddLogMasterDbLogSink(
    async (_, cancellationToken) =>
    {
        var connection = new SqlConnection(
            builder.Configuration.GetConnectionString("DefaultConnection"));

        await connection.OpenAsync(cancellationToken);
        return connection;
    },
    includeLoggerSink: true);

The DB log sink creates this SQL Server table automatically:

CREATE TABLE [dbo].[LogMasterHttpLogs]
(
    [Id] bigint IDENTITY(1,1) NOT NULL PRIMARY KEY,
    [TimestampUtc] datetime2(7) NOT NULL,
    [TraceId] nvarchar(100) NOT NULL,
    [Method] nvarchar(20) NOT NULL,
    [Path] nvarchar(2048) NOT NULL,
    [QueryString] nvarchar(max) NULL,
    [StatusCode] int NOT NULL,
    [ElapsedMs] float NOT NULL,
    [UserName] nvarchar(256) NULL,
    [RemoteIpAddress] nvarchar(100) NULL,
    [RequestHeaders] nvarchar(max) NULL,
    [ResponseHeaders] nvarchar(max) NULL,
    [RequestBody] nvarchar(max) NULL,
    [ResponseBody] nvarchar(max) NULL,
    [ExceptionType] nvarchar(512) NULL,
    [ExceptionMessage] nvarchar(max) NULL
);

Admin API

Get current settings:

GET /admin/logging/detailed

Update all settings:

PUT /admin/logging/detailed
Content-Type: application/json

{
  "enabled": true,
  "logRequestBody": true,
  "logResponseBody": true,
  "logHeaders": true,
  "logQueryString": true,
  "logOnlyErrors": false,
  "maxBodyLength": 10000,
  "excludedPaths": ["/health", "/swagger", "/metrics"],
  "sensitiveFields": ["authorization", "cookie", "password", "token"]
}

Only toggle enabled/disabled:

POST /admin/logging/detailed/enabled
Content-Type: application/json

{
  "enabled": false
}

Admin panel usage

Your admin panel can call:

  • GET /admin/logging/detailed to load the current form state.
  • POST /admin/logging/detailed/enabled for a simple switch.
  • PUT /admin/logging/detailed when editing detailed options.

For production, keep RequireAuthorization = true and protect the route with an admin-only policy.

Create and publish the NuGet package

Create the package:

dotnet pack .\LogMaster\LogMaster.csproj -c Release

The .nupkg file is written to:

artifacts/packages

Publish to nuget.org:

dotnet nuget push .\artifacts\packages\LogMaster.NetCore.0.1.0.nupkg --api-key YOUR_NUGET_API_KEY --source https://api.nuget.org/v3/index.json

Before publishing publicly, check that LogMaster.NetCore is available on nuget.org. If it is already taken, change <PackageId> in LogMaster/LogMaster.csproj.

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.
  • net8.0

    • No dependencies.

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.5 143 6/24/2026
0.1.4 128 6/24/2026
0.1.2 117 6/12/2026
0.1.1 119 6/11/2026
0.1.0 107 6/11/2026