Gleeman.EffectiveLogger.MySQL 2.0.1

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.1
NuGet\Install-Package Gleeman.EffectiveLogger.MySQL -Version 2.0.1
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.1" />
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.1
#r "nuget: Gleeman.EffectiveLogger.MySQL, 2.0.1"
#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.1

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

Gleeman Effective Logger

dotnet CLI

> dotnet add package Gleeman.EffectiveLogger --version 2.0.2
> dotnet add package Gleeman.EffectiveLogger.SQLite --version 2.0.1
> dotnet add package Gleeman.EffectiveLogger.MSSqlServer --version 2.0.2
> dotnet add package Gleeman.EffectiveLogger.PostgreSQL --version 2.0.1
> dotnet add package Gleeman.EffectiveLogger.MySQL --version 2.0.1

How To Use?

appsettings.json
{
  "LogOptions": {
    "WriteToFile": true, // true or false
    "WriteToDatabase": true, // true or false
    // if WriteToFile is true, you should to write here 'FilePath' and 'FileName'
    "FilePath": "", 
    "FileName": "",
    "DatabaseOptions": {
      // if WriteToDatabase is true, you should to write here 'connection string'
      "SQLiteConnectionString": "",
      "MSSqlServerConectionString": "",
      "PostgreSqlConnectionString": "",
      "MySqlConnectionString": ""
    }
  }
}
program.cs
Logging to SQLite
builder.Logging.ClearProviders();
builder.Services.AddEffectiveLogger(builder.Configuration)
                .AddSQLiteLog(builder.Configuration, assembly: Assembly.GetExecutingAssembly());
Logging to MSSqlServer
builder.Logging.ClearProviders();
builder.Services.AddEffectiveLogger(builder.Configuration)
                .AddMSSqlServerLog(builder.Configuration, assembly: Assembly.GetExecutingAssembly());
Logging to PostgreSql
builder.Logging.ClearProviders();
builder.Services.AddEffectiveLogger(builder.Configuration)
                .AddPostgreSqlLog(builder.Configuration, assembly: Assembly.GetExecutingAssembly());
Logging to MySQL
builder.Logging.ClearProviders();

builder.Services.AddEffectiveLogger(builder.Configuration)
                .AddMySqlLog(builder.Configuration,assembly:Assembly.GetExecutingAssembly());
Only console and file logging is possible
builder.Logging.ClearProviders();
builder.Services.AddEffectiveLogger(builder.Configuration);
Middleware or Controller
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)
    {
        _log.Debug($"{context.Request.Method}");
        try
        {
            _log.Information($"{context.Request.Method} {context.Response.StatusCode}");
            await next.Invoke(context);
        }
        catch (Exception ex)
        {
            _log.Fail($"{context.Request.Method} - {ex.Message.ToString()}");
        }
    }
}
Controller
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        private readonly IEffectiveLog<ValuesController> _log;

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

        [HttpGet]
        public IActionResult Get()
        {
            _log.Information("Information");
            _log.Debug("Debug");

            var values = new List<string>()
            {
                "Value1",
                "Value2",
                "Value3",
                "Value4",

            };
            _log.Fail("Fail");
            _log.Warning("Warning");

            return Ok(values);
        }
    }

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 78 2/2/2024
2.0.5 114 9/29/2023
2.0.1 94 9/19/2023