Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gleeman Effective Logger

SQLite

Install packages

dotnet CLI

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

Program.cs

using Gleeman.EffectiveLogger.SQLite.Configurations;
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();
});

MSSQLServer

Install packages

dotnet CLI

dotnet add package Gleeman.EffectiveLogger --version 2.0.6
dotnet add package Gleeman.EffectiveLogger.MSSqlServer --version 2.0.5

Program.cs

using Gleeman.EffectiveLogger.MSSqlServer.Configurations;
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();
});

MySQL

Install packages

dotnet CLI

dotnet add package Gleeman.EffectiveLogger --version 2.0.6
dotnet add package Gleeman.EffectiveLogger.MySQL --version 2.0.5

Program.cs

using Gleeman.EffectiveLogger.MySQL.Configurations;
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();
});

PostgreSQL

Install packages

dotnet CLI

dotnet add package Gleeman.EffectiveLogger --version 2.0.6
dotnet add package Gleeman.EffectiveLogger.PostgreSQL --version 2.0.5

Program.cs

using Gleeman.EffectiveLogger.PostgreSQL.Configurations;
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();
});

USAGE

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($"{context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");
            _log.Debug($"{context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");
            _log.Fail($"{context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");
            _log.Warning($"{context.Request.Method} - {context.Request.Path} - {context.Response.StatusCode}");

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

Console Screen

Console

File Screen

File

Database Screen

Database

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.