mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-31 15:19:28 +02:00
Added Serilog to manage logs
Handle required fields while starting
This commit is contained in:
parent
6fbfaa1007
commit
b128154c60
17 changed files with 749 additions and 154 deletions
|
@ -1,15 +1,12 @@
|
|||
using Hangfire;
|
||||
using Hangfire.Storage.SQLite;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using MTWireGuard.Application.Mapper;
|
||||
using MTWireGuard.Application.Repositories;
|
||||
using MTWireGuard.Application.Services;
|
||||
using Serilog;
|
||||
using Serilog.Ui.SqliteDataProvider;
|
||||
using Serilog.Ui.Web;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace MTWireGuard.Application
|
||||
{
|
||||
|
@ -17,16 +14,15 @@ namespace MTWireGuard.Application
|
|||
{
|
||||
public static void AddApplicationServices(this IServiceCollection services)
|
||||
{
|
||||
// Add Serilog
|
||||
services.AddLogging(loggingBuilder =>
|
||||
{
|
||||
loggingBuilder.AddSerilog(Helper.LoggerConfiguration(), dispose: true);
|
||||
});
|
||||
|
||||
// Add DBContext
|
||||
services.AddDbContext<DBContext>();
|
||||
|
||||
// Add HangFire
|
||||
services.AddHangfire(config =>
|
||||
{
|
||||
config.UseSQLiteStorage(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "MikrotikWireguard.db"));
|
||||
});
|
||||
services.AddHangfireServer();
|
||||
|
||||
// Auto Mapper Configurations
|
||||
services.AddSingleton<PeerMapping>();
|
||||
services.AddSingleton<ServerMapping>();
|
||||
|
@ -79,6 +75,9 @@ namespace MTWireGuard.Application
|
|||
o.Conventions.AllowAnonymousToPage("/Login");
|
||||
});
|
||||
|
||||
// Add HttpContextAccessor
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
// Add Session
|
||||
services.AddDistributedMemoryCache();
|
||||
|
||||
|
@ -91,6 +90,12 @@ namespace MTWireGuard.Application
|
|||
|
||||
// Add CORS
|
||||
services.AddCors();
|
||||
|
||||
// Add SerilogUI
|
||||
services.AddSerilogUi(options =>
|
||||
{
|
||||
options.UseSqliteServer($"Data Source={Helper.GetLogPath("logs.db")}", "Logs");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue