dotnet CLI
dotnet add package Gleeman.EffectiveLogger --version 2.0.6
dotnet add package Gleeman.EffectiveLogger.SQLite --version 2.0.5
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();
});
dotnet CLI
dotnet add package Gleeman.EffectiveLogger --version 2.0.6
dotnet add package Gleeman.EffectiveLogger.MSSqlServer --version 2.0.5
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();
});
dotnet CLI
dotnet add package Gleeman.EffectiveLogger --version 2.0.6
dotnet add package Gleeman.EffectiveLogger.MySQL --version 2.0.5
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();
});
dotnet CLI
dotnet add package Gleeman.EffectiveLogger --version 2.0.6
dotnet add package Gleeman.EffectiveLogger.PostgreSQL --version 2.0.5
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();
});
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}");
}
}
}