RSoft.Logs 1.0.0-preview200904.1

Logging mechanism for elastic (direct mode) and terminal console

This is a prerelease version of RSoft.Logs.
There is a newer version of this package available.
See the version list below for details.
Install-Package RSoft.Logs -Version 1.0.0-preview200904.1
dotnet add package RSoft.Logs --version 1.0.0-preview200904.1
<PackageReference Include="RSoft.Logs" Version="1.0.0-preview200904.1" />
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-preview200904.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RSoft.Logs, 1.0.0-preview200904.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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-preview200904.1&prerelease

// Install RSoft.Logs as a Cake Tool
#tool nuget:?package=RSoft.Logs&version=1.0.0-preview200904.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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 inl1.0.0-preview200831.1 .NET Cli: dotnet add package RSoft.Logs --version 1.0.0-preview200831.1 Package Reference: <PackageReference Include="RSoft.Logs" Version="1.0.0-preview200831.1" /> Paket Cli: paket add RSoft.Logs --version 1.0.0-preview200831.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

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 inl1.0.0-preview200831.1 .NET Cli: dotnet add package RSoft.Logs --version 1.0.0-preview200831.1 Package Reference: <PackageReference Include="RSoft.Logs" Version="1.0.0-preview200831.1" /> Paket Cli: paket add RSoft.Logs --version 1.0.0-preview200831.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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.2 64 9/8/2021
1.2.1 55 9/8/2021
1.2.0 64 9/8/2021
1.1.0 59 8/26/2021
1.1.0-rc1.7 56 8/6/2021
1.1.0-rc1.6 66 5/31/2021
1.1.0-rc1.5 55 5/30/2021
1.1.0-rc1.4 52 5/27/2021
1.1.0-rc1.3 64 4/22/2021
1.1.0-rc1.2 51 4/21/2021
1.1.0-rc1.1 59 4/20/2021
1.1.0-rc1.0 49 4/19/2021
1.0.0 144 11/18/2020
1.0.0-rc1.7 233 10/18/2020
1.0.0-rc1.6 115 10/15/2020
1.0.0-rc1.4 152 10/10/2020
1.0.0-rc1.3 229 9/26/2020
1.0.0-rc1.2 156 9/23/2020
1.0.0-rc1.1 173 9/22/2020
1.0.0-rc1.0 178 9/16/2020
1.0.0-preview200914.2 160 9/14/2020
1.0.0-preview200904.1 240 9/4/2020
1.0.0-preview200831.1 156 8/31/2020
Show less