RSoft.Logs 1.0.0-preview200914.2

This is a prerelease version of RSoft.Logs.
There is a newer version of this package available.
See the version list below for details.
dotnet add package RSoft.Logs --version 1.0.0-preview200914.2
NuGet\Install-Package RSoft.Logs -Version 1.0.0-preview200914.2
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="RSoft.Logs" Version="1.0.0-preview200914.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RSoft.Logs --version 1.0.0-preview200914.2
#r "nuget: RSoft.Logs, 1.0.0-preview200914.2"
#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.
// Install RSoft.Logs as a Cake Addin
#addin nuget:?package=RSoft.Logs&version=1.0.0-preview200914.2&prerelease

// Install RSoft.Logs as a Cake Tool
#tool nuget:?package=RSoft.Logs&version=1.0.0-preview200914.2&prerelease

RSoft.Logs

Logging mechanism for elastic (direct mode) and terminal console

RSoft.Logs is a provider of logging mechanisms based on the standard .Net Core ILogger interface. The available resources are:

  • Elastic logger provider
  • Console logger provider
  • Middlware API Request/Response logger

Dependencies

RSoft.Logs has the following dependencies.

  • Microsoft.AspNetCore.Hosting (>= 2.2.7)
  • Microsoft.AspNetCore.Http (>= 2.2.2)
  • Microsoft.Extensions.Http (>= 3.1.7)
  • Microsoft.Extensions.Logging (>= 3.1.7)
  • Microsoft.Extensions.Logging.Abstractions (>= 3.1.7)
  • Microsoft.Extensions.Logging.Configuration (>= 3.1.7)
  • System.Configuration.ConfigurationManager (>= 4.7.0)
  • System.Text.Json (>= 5.0.0-preview.8.20407.11)¹

¹ WARNING: RSoft.Logs uses version 5.0-preview of the System.Text.Json package. This version is not yet stable and therefore the RSoft.Logs package will maintain the same condition until the final version of this version is released.

Installaction

  • PackageManage: Install-Package RSoft.Logs -Version 1.0.0-preview200904.1
  • .NET Cli: dotnet add package RSoft.Logs --version 1.0.0-preview200904.1
  • Package Reference: <PackageReference Include="RSoft.Logs" Version="1.0.0-preview200904.1" />
  • Paket Cli: paket add RSoft.Logs --version 1.0.0-preview200904.1

Configuration

The configuration of all the mechanisms of this package are done through the appsettings.json of the application, in the section Logging as complete complete below

"Logging": {
    "LogLevel": {
      [--- LogLevel default microsoft configuration ---]
    },
    "Elastic": {
      "Uri": "http://localhost:9200",
      "DefaultIndexName": "my-index-name",
      "IgnoreCategories": [
        "Microsoft.Hosting.Lifetime"
      ]
    },
    "RequestResponseMiddleware": {
      "LogRequest": true,
      "LogResponse": true,
      "SecurityActions": [
        {
          "Method": "POST",
          "Path": "/api/auth"
        }
      ]
    }
  }
Elastic Section configuration
  • Uri ⇒ Elastic Service url running
  • DefaultIndxName ⇒ Name of the document index to save the logs
  • IgnoreCategoris ⇒ List of categories to ignore in the log record.
RequestResponseMiddleware Section configuration
  • LogRequest ⇒ Enables or disables request logging (disabled by default)
  • LogReponse ⇒ Enables or disables response logging (disabled by default)
  • SecurityActions → List of keys Method + Action that will have the request body hidden in the log recording. Use this section to indicate points where sensitive information, such as a password for example, is being trafficked.

Implementation in your application

In the program.cs file, add the calls to the desired modules to the ConfigureLogging section, according to the model below::

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using RSoft.Logs.Extensions;

namespace MyApplication.Web.Api
{
	public class Program
    {
		public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }
		
		public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureLogging(logging =>
                {
                    logging.ClearProviders();
                    logging.AddConsoleLogger();
                    logging.AddElasticLogger();
                })
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}

In the Startup.cs file add the following codes: .

In ConfigureServices method add the line:

services.AddMiddlewareLoggingOption(Configuration);

In Configure method add the line:

app.UseMiddleware<RequestResponseLogging<Startup>>();

That's all you need.

THANK'S
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.3.2 464 8/3/2022
1.3.1 395 10/10/2021
1.3.0 345 10/6/2021
1.2.2 362 9/8/2021
1.2.1 350 9/8/2021
1.2.0 348 9/8/2021
1.1.0 330 8/26/2021
1.1.0-rc1.7 153 8/6/2021
1.1.0-rc1.6 188 5/31/2021
1.1.0-rc1.5 156 5/30/2021
1.1.0-rc1.4 135 5/27/2021
1.1.0-rc1.3 157 4/22/2021
1.1.0-rc1.2 139 4/21/2021
1.1.0-rc1.1 146 4/20/2021
1.1.0-rc1.0 139 4/19/2021
1.0.0 442 11/18/2020
1.0.0-rc1.7 327 10/18/2020
1.0.0-rc1.6 197 10/15/2020
1.0.0-rc1.4 236 10/10/2020
1.0.0-rc1.3 317 9/26/2020
1.0.0-rc1.2 244 9/23/2020
1.0.0-rc1.1 259 9/22/2020
1.0.0-rc1.0 273 9/16/2020
1.0.0-preview200914.2 255 9/14/2020
1.0.0-preview200904.1 323 9/4/2020
1.0.0-preview200831.1 258 8/31/2020