This commit is contained in:
Zeeshaun
2026-04-07 14:04:08 +00:00
parent cf7bed0de4
commit 63a69556e1
@@ -1,5 +1,8 @@
using Serilog; using Serilog;
using Serilog.Events;
using System.Net; using System.Net;
using System.Configuration;
using System.IO;
using System.Web.Http; using System.Web.Http;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.Routing; using System.Web.Routing;
@@ -9,7 +12,7 @@ namespace LCU.API.Internal.CoreSoapApiWrapper
{ {
public class WebApiApplication : System.Web.HttpApplication public class WebApiApplication : System.Web.HttpApplication
{ {
protected void Application_Start() protected void Application_Start()
{ {
AreaRegistration.RegisterAllAreas(); AreaRegistration.RegisterAllAreas();
IocBootstrapper.Run(); IocBootstrapper.Run();
@@ -24,8 +27,22 @@ namespace LCU.API.Internal.CoreSoapApiWrapper
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
var seqApiKey = ConfigurationManager.AppSettings["serilog:write-to:Seq.apiKey"];
try
{
seqApiKey = File.ReadAllText("/vault/secrets/core-soap-api-wrapper-api-seq-api-key.json").Trim();
}
catch (IOException)
{
// Fall back to the configured app setting when the secret file is not mounted.
}
catch (UnauthorizedAccessException)
{
// Fall back to the configured app setting when the secret file is not readable.
}
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
.ReadFrom.AppSettings() .MinimumLevel.Verbose()
.Enrich.WithMachineName() .Enrich.WithMachineName()
.Enrich.WithEnvironmentUserName() .Enrich.WithEnvironmentUserName()
.Enrich.WithHttpRequestClientHostIP() .Enrich.WithHttpRequestClientHostIP()
@@ -38,6 +55,9 @@ namespace LCU.API.Internal.CoreSoapApiWrapper
.Enrich.WithWebApiControllerName() .Enrich.WithWebApiControllerName()
.Enrich.WithWebApiRouteData() .Enrich.WithWebApiRouteData()
.Enrich.WithWebApiRouteTemplate() .Enrich.WithWebApiRouteTemplate()
.WriteTo.Console()
.WriteTo.File(ConfigurationManager.AppSettings["serilog:write-to:File.path"], rollingInterval: RollingInterval.Day, retainedFileCountLimit: 4)
.WriteTo.Seq(ConfigurationManager.AppSettings["serilog:write-to:Seq.serverUrl"], LogEventLevel.Information, 1000, null, seqApiKey)
.CreateLogger(); .CreateLogger();
Log.Information("Core Soap Api Wrapper Starting Up"); Log.Information("Core Soap Api Wrapper Starting Up");