Gleeman.EffectiveLogger.MySQL 2.0.5

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

// Install Gleeman.EffectiveLogger.MySQL as a Cake Tool
#tool nuget:?package=Gleeman.EffectiveLogger.MySQL&version=2.0.5                

Gleeman Effective Logger

dotnet CLI

> dotnet add package Gleeman.EffectiveLogger.SQLite --version 2.0.5
> dotnet add package Gleeman.EffectiveLogger --version 2.0.5

<hr>

How To Use?

Logging to SQLite

Install packages

dotnet CLI

> dotnet add package Gleeman.EffectiveLogger.SQLite --version 2.0.5
> dotnet add package Gleeman.EffectiveLogger --version 2.0.5
Program.cs
builder.Services.AddSQLiteLog(options =>
{
    options.ConnectionString = "Connection string is here";
    options.WriteToFile = true;
    options.WriteToConsole = true;
    options.FilePath = "File path is here";
    options.FileName = "File name is here";
    options.MigrationAssembly = Assembly.GetExecutingAssembly();
});

Logging to MSSQLServer

Install packages

dotnet CLI

> dotnet add package Gleeman.EffectiveLogger.MSSqlServer --version 2.0.5
> dotnet add package Gleeman.EffectiveLogger --version 2.0.5
builder.Services.AddMSSqlServerLog(options =>
{
    options.ConnectionString = "Connection string is here";
    options.WriteToFile = true;
    options.WriteToConsole = true;
    options.FilePath = "File path is here";
    options.FileName = "File name is here";
    options.MigrationAssembly = Assembly.GetExecutingAssembly();
});

Logging to MySQL

Install packages

dotnet CLI

> dotnet add package Gleeman.EffectiveLogger.MySQL --version 2.0.5
> dotnet add package Gleeman.EffectiveLogger --version 2.0.5
builder.Services.AddMySqlLog(options =>
{
    options.ConnectionString = "Connection string is here";
    options.WriteToFile = true;
    options.WriteToConsole = true;
    options.FilePath = "File path is here";
    options.FileName = "File name is here";
    options.MigrationAssembly = Assembly.GetExecutingAssembly();
});

Logging to PostgreSQL

Install packages

dotnet CLI

> dotnet add package Gleeman.EffectiveLogger.PostgreSQL --version 2.0.5
> dotnet add package Gleeman.EffectiveLogger --version 2.0.5
builder.Services.AddPostgreSqlLog(options =>
{
    options.ConnectionString = "Connection string is here";
    options.WriteToFile = true;
    options.WriteToConsole = true;
    options.FilePath = "File path is here";
    options.FileName = "File name is here";
    options.MigrationAssembly = Assembly.GetExecutingAssembly();
});

<hr>

Middleware

public class LoggingMiddleware : IMiddleware
{
    private readonly IEffectiveLog<LoggingMiddleware> _log;

    public LoggingMiddleware(IEffectiveLog<LoggingMiddleware> log)
    {
        _log = log;
    }

    public async Task InvokeAsync(HttpContext context, RequestDelegate next)
    {
        try
        {
            _log.Information($"{DateTime.Now} - {context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");
            _log.Debug($"{DateTime.Now} - {context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");
            _log.Fail($"{DateTime.Now} - {context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");
            _log.Warning($"{DateTime.Now} - {context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");

            await next.Invoke(context);
        }
        catch (Exception ex)
        {
           _log.Fail($"{DateTime.Now} - {context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode} - {ex.Message}");
        }
    }
}

Console Screen

Console

File Screen

File

Database Screen

Database

Product Compatible and additional computed target framework versions.
.NET 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 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. 
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
2.0.6 103 2/2/2024
2.0.5 139 9/29/2023
2.0.1 118 9/19/2023