diff --git a/ApiDto/Requests/Configuration/LoggingRequest.cs b/ApiDto/Requests/Configuration/LoggingRequest.cs
index eba6428..3108f8a 100644
--- a/ApiDto/Requests/Configuration/LoggingRequest.cs
+++ b/ApiDto/Requests/Configuration/LoggingRequest.cs
@@ -22,4 +22,17 @@ public class LoggingRequest
/// Gets or sets the log file path.
///
public string? LogFilePath { get; set; }
+
+ ///
+ /// Gets or sets the API key for integrating with Seq, a log aggregation service.
+ /// If provided, logs will be sent to a Seq server using this API key.
+ ///
+ public string? ApiKeySeq { get; set; }
+
+ ///
+ /// Gets or sets the server URL for the Seq logging service.
+ /// This property specifies the Seq server endpoint to which logs will be sent.
+ /// If is provided, logs will be sent to this server.
+ ///
+ public string? ApiServerSeq { get; set; }
}
\ No newline at end of file
diff --git a/Endpoint/Configuration/Core/Middleware/MaintenanceModeMiddleware.cs b/Endpoint/Configuration/Core/Middleware/MaintenanceModeMiddleware.cs
index adfee69..8377a93 100644
--- a/Endpoint/Configuration/Core/Middleware/MaintenanceModeMiddleware.cs
+++ b/Endpoint/Configuration/Core/Middleware/MaintenanceModeMiddleware.cs
@@ -24,7 +24,6 @@ public class MaintenanceModeMiddleware(RequestDelegate next, IMaintenanceModeSer
context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
context.Response.ContentType = "plain/text";
- string error;
if (maintenanceModeService.IsMaintenanceMode)
throw new ServerUnavailableException("The service is currently undergoing maintenance. Please try again later.", true);
diff --git a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs
index 2e10259..238ad22 100644
--- a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs
+++ b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs
@@ -45,6 +45,12 @@ public static class LoggerConfiguration
rollingInterval: RollingInterval.Day);
}
+#if !DEBUG
+ if (generalConfig != null && !string.IsNullOrEmpty(generalConfig.ApiServerSeq) &&
+ Uri.TryCreate(generalConfig.ApiServerSeq, UriKind.Absolute, out var _))
+ configuration.WriteTo.Seq(generalConfig.ApiServerSeq, apiKey: generalConfig.ApiKeySeq);
+#endif
+
configuration
.MinimumLevel.Override("Microsoft.AspNetCore.Hosting", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore.Mvc", LogEventLevel.Warning)
diff --git a/Endpoint/Configuration/Model/GeneralSettings/LogSettings.cs b/Endpoint/Configuration/Model/GeneralSettings/LogSettings.cs
index 3f8deb1..c5fafe0 100644
--- a/Endpoint/Configuration/Model/GeneralSettings/LogSettings.cs
+++ b/Endpoint/Configuration/Model/GeneralSettings/LogSettings.cs
@@ -9,6 +9,8 @@ public class LogSettings : IIsConfigured
public bool EnableLogToFile { get; set; }
public string? LogFilePath { get; set; }
public string? LogFileName { get; set; }
+ public string? ApiKeySeq { get; set; }
+ public string? ApiServerSeq { get; set; }
public bool IsConfigured()
{
diff --git a/Endpoint/Controllers/Configuration/SetupController.cs b/Endpoint/Controllers/Configuration/SetupController.cs
index 5ab4671..ab17c64 100644
--- a/Endpoint/Controllers/Configuration/SetupController.cs
+++ b/Endpoint/Controllers/Configuration/SetupController.cs
@@ -22,6 +22,7 @@ using Mirea.Api.Security.Common.Domain;
using Mirea.Api.Security.Services;
using MySqlConnector;
using Npgsql;
+using Serilog;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
@@ -408,6 +409,29 @@ public class SetupController(
}
};
+ if (!string.IsNullOrEmpty(request?.ApiServerSeq))
+ {
+ settings.ApiServerSeq = request.ApiServerSeq;
+ settings.ApiKeySeq = request.ApiKeySeq;
+
+ try
+ {
+ Log.Logger = new LoggerConfiguration()
+ .WriteTo.Seq(settings.ApiServerSeq, apiKey: settings.ApiKeySeq)
+ .CreateLogger();
+
+ Log.Warning("Testing configuration Seq.");
+ }
+ catch
+ {
+ // ignoring
+ }
+ finally
+ {
+ Log.CloseAndFlush();
+ }
+ }
+
if (settings.EnableLogToFile)
{
if (string.IsNullOrEmpty(settings.LogFileName))
@@ -427,7 +451,9 @@ public class SetupController(
{
EnableLogToFile = settings.EnableLogToFile,
LogFileName = settings.LogFileName,
- LogFilePath = settings.LogFilePath
+ LogFilePath = settings.LogFilePath,
+ ApiKeySeq = settings.ApiKeySeq,
+ ApiServerSeq = settings.ApiServerSeq
});
return true;
diff --git a/Endpoint/Endpoint.csproj b/Endpoint/Endpoint.csproj
index 2175de9..2692750 100644
--- a/Endpoint/Endpoint.csproj
+++ b/Endpoint/Endpoint.csproj
@@ -50,6 +50,7 @@
+