Improvements for home page and formatting
This commit is contained in:
+22
-7
@@ -7,6 +7,7 @@ using System.Text.Json;
|
||||
using WebApp;
|
||||
using WebApp.Authentication;
|
||||
using WebApp.Components;
|
||||
using WebApp.Logging;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -66,18 +67,32 @@ if (builder.Environment.IsProduction())
|
||||
}
|
||||
}
|
||||
|
||||
// Configure Serilog
|
||||
// Configure Serilog with custom handling for antiforgery errors
|
||||
builder.Host.UseSerilog((context, configuration) =>
|
||||
configuration
|
||||
.ReadFrom.Configuration(context.Configuration)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console(
|
||||
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}")
|
||||
{
|
||||
var consoleOutputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}";
|
||||
var fileOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}";
|
||||
|
||||
// Create console logger with antiforgery error handling
|
||||
var consoleConfig = new LoggerConfiguration()
|
||||
.WriteTo.Console(outputTemplate: consoleOutputTemplate);
|
||||
var consoleLogger = consoleConfig.CreateLogger();
|
||||
|
||||
// Create file logger with antiforgery error handling
|
||||
var fileConfig = new LoggerConfiguration()
|
||||
.WriteTo.File(
|
||||
path: "logs/webapp-.txt",
|
||||
rollingInterval: RollingInterval.Day,
|
||||
retainedFileCountLimit: 30,
|
||||
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}"));
|
||||
outputTemplate: fileOutputTemplate);
|
||||
var fileLogger = fileConfig.CreateLogger();
|
||||
|
||||
configuration
|
||||
.ReadFrom.Configuration(context.Configuration)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Sink(new AntiforgeryLogEventSink(consoleLogger))
|
||||
.WriteTo.Sink(new AntiforgeryLogEventSink(fileLogger));
|
||||
});
|
||||
|
||||
// Configure authentication secrets for production (Docker, etc.)
|
||||
if (builder.Environment.IsProduction())
|
||||
|
||||
Reference in New Issue
Block a user