ServiceBricks.Logging.Microservice 1.4.0

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

ServiceBricks Logo

NuGet version badge License: MIT

ServiceBricks Logging Microservice

Overview

This repository contains the logging microservice built using the ServiceBricks foundation. The logging microservice provides logging support for any hosted application using the Microsoft.Extensions.Logging library. It provides web request logging functionality, so you can audit all web requests coming into the application.

Data Transfer Objects

LogMessageDto - Admin Policy

Used to store application diagnositics.


public class LogMessageDto : DataTransferObject
{
    public virtual DateTimeOffset CreateDate { get; set; }
    public virtual string Application { get; set; }
    public virtual string Server { get; set; }
    public virtual string Category { get; set; }
    public virtual string UserStorageKey { get; set; }
    public virtual string Path { get; set; }
    public virtual string Level { get; set; }
    public virtual string Message { get; set; }
    public virtual string Exception { get; set; }
    public virtual string Properties { get; set; }
}

Business Rules
  • DomainCreateDateRule - CreateDate property

WebRequestMessageDto - Admin Policy

Used to store web request auditing messages.


 public class WebRequestMessageDto : DataTransferObject
 {
     public DateTimeOffset CreateDate { get; set; }
     public string RequestIPAddress { get; set; }
     public string RequestProtocol { get; set; }
     public string RequestScheme { get; set; }
     public string RequestMethod { get; set; }
     public string RequestBody { get; set; }
     public string RequestPath { get; set; }
     public string RequestPathBase { get; set; }
     public string RequestQueryString { get; set; }
     public string RequestQuery { get; set; }
     public string RequestRouteValues { get; set; }
     public string RequestHost { get; set; }
     public bool? RequestHasFormContentType { get; set; }
     public string RequestCookies { get; set; }
     public string RequestContentType { get; set; }
     public long? RequestContentLength { get; set; }
     public string RequestHeaders { get; set; }
     public bool? RequestIsHttps { get; set; }
     public string RequestUserId { get; set; }
     public int? ResponseStatusCode { get; set; }
     public string ResponseHeaders { get; set; }
     public string ResponseCookies { get; set; }
     public string ResponseContentType { get; set; }
     public long? ResponseContentLength { get; set; }
     public long? ResponseTotalMilliseconds { get; set; }
     public string ResponseBody { get; set; }
 }

Business Rules
  • DomainCreateDateRule - CreateDate property

Background Tasks and Timers

LoggingWriteMessageTimer class

This background timer runs executes the LoggingWriteMessageTask.

View Source

LoggingWriteMessageTask class

This background task pulls records off of custom logger inmemory queue and writes them to the ILogMessageAPIService.

View Source

Events

None

Middleware

LogMessageMiddleware

This middleware is responsible for plugging into the pipeline and storing minimal HttpRequest information (such as user, request, path, etc) to store along with log messages.

In your program.cs file, add the custom logger with AddServiceBricksLogging() in the ConfigureLogging section.


    .ConfigureLogging((hostingContext, logging) =>
    {
        logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
        logging.AddConsole();
        logging.AddDebug();
        logging.AddServiceBricksLogging();
    })

The following code should be added to your web application's startup. This middleware should be added to the pipeline after UseAuth() so that any authenticated user is available.

  app.UseMiddleware<LogMessageMiddleware>();

View Source

WebRequestMessageMiddleware class

This middleware is responsible for plugging into the pipeline and pulling the HttpRequest and HttpResponse properties of the current web request and storing them for auditing purposes.

The following code should be added to your web application's startup. This middleware should be added to the pipeline after UseAuth(), so that any authenticated user is available.

  app.UseMiddleware<WebRequestMessageMiddleware>();

View Source

Processes

None

Service Bus

CreateApplicationLogBroadcast

This microservice subscribes to the CreateApplicationLogBroadcast message. It is associated to the CreateApplicationLogRule Business Rule. When receiving the message, it will simply create a record in storage.


public class CreateApplicationLogBroadcast : DomainBroadcast<ApplicationLogDto>
{
    public CreateApplicationLogBroadcast(ApplicationLogDto obj)
    {
        DomainObject = obj;
    }
}

Additional

None

Application Settings

{
  // System default logging option
  "Logging": {
    "LogLevel": {
      // Specify custom logging levels for components here
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.AspNetCore": "Warning",
      "Microsoft.Hosting.Lifetime": "Warning"
    }
  },

  // ServiceBricks Settings
  "ServiceBricks": {

    // Logging Microservice Settings
    "Logging": {

      // WebRequestMessageMiddleware Settings
      "WebRequestMessage": {
      "EnableLogging": false,
      "EnableExceptions": true,
      "EnableUserStorageKey": true,
      "EnableRequestIPAddress": true,
      "EnableRequestBody": true,
      "EnableRequestBodyOnError": true,
      "EnableRequestProtocol": true,
      "EnableRequestScheme": true,
      "EnableRequestMethod": true,
      "EnableRequestPath": true,
      "EnableRequestPathBase": true,
      "EnableRequestQueryString": true,
      "EnableRequestQuery": true,
      "EnableRequestRouteValues": true,
      "EnableRequestHost": true,
      "EnableRequestHasFormContentType": true,
      "EnableRequestCookies": true,
      "EnableRequestContentType": true,
      "EnableRequestContentLength": true,
      "EnableRequestHeaders": true,
      "EnableRequestIsHttps": true,
      "EnableResponseStatusCode": true,
      "EnableResponseHeaders": true,
      "EnableResponseCookies": true,
      "EnableResponseContentType": true,
      "EnableResponseContentLength": true,
      "EnableResponseTotalMilliseconds": true,
      "EnableResponseBody": true,
      "EnableExcludeRequestPathsRegExExpressions": false,
      "ExcludeRequestPaths": [
        //"/css/",
        //"/img/",
        //"/js/",
      ],
      "EnableExcludeIpAddressesRegExExpressions": false,
      "ExcludeIpAddresses": [
        // "127.0.0.1",
        // "::1"
      ]
    }
   }
  }
}

About ServiceBricks

ServiceBricks is the cornerstone for building a microservices foundation. Visit https://ServiceBricks.com to learn more.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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 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
1.4.0 0 1/1/2026
1.4.0-e 259 12/18/2025
1.4.0-d 255 12/16/2025
1.4.0-c 140 12/14/2025
1.4.0-b 135 12/13/2025
1.4.0-a 295 12/8/2025
1.3.0 303 3/18/2025
1.3.0-c 190 3/16/2025
1.3.0-a 145 1/27/2025
1.2.0 130 1/14/2025
1.1.3 166 12/1/2024