mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 21:01:10 +00:00
Sets Serilog file configuration for all setups and environments
This commit is contained in:
1 parent
6022800776
commit
181c681813
9 files changed
+31
-13
No files matched your search
@@ -1,9 +1,9 @@
|
||||
# This stage is used when running from VS in fast mode (Default for Debug configuration)
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
RUN mkdir /logs && chown -R app:app /logs
|
||||
USER app
|
||||
WORKDIR /app
|
||||
EXPOSE 5214
|
||||
EXPOSE 7057
|
||||
|
||||
# ==== Stage 1: Build stage
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
@@ -50,9 +50,7 @@ WORKDIR /app
|
||||
|
||||
COPY --from=publish /app/publish .
|
||||
ENV ASPNETCORE_HTTP_PORTS=5214
|
||||
ENV ASPNETCORE_HTTPS_PORTS=7057
|
||||
EXPOSE 5214
|
||||
EXPOSE 7057
|
||||
ENTRYPOINT ["dotnet", "Lumina.Presentation.Api.dll"]
|
||||
|
||||
# to build this Docker image, run the following command from the root of the project (location of the .sln file):
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
|
||||
<PackageReference Include="Serilog.Enrichers.AspnetcoreHttpcontext" Version="1.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -8,6 +8,7 @@ using Lumina.Domain.Common.DependencyInjection;
|
||||
using Lumina.Infrastructure.Common.DependencyInjection;
|
||||
using Lumina.Presentation.Api.Common.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -45,10 +46,18 @@ public class Program
|
||||
// determine log path based on environment
|
||||
string logPath;
|
||||
if (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true")
|
||||
{
|
||||
logPath = Environment.GetEnvironmentVariable("LOG_PATH") ?? "/logs"; // use docker volume path
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.ListenAnyIP(5214); // HTTP only
|
||||
});
|
||||
}
|
||||
else
|
||||
logPath = Path.Combine(AppContext.BaseDirectory, "logs"); // use local binary path
|
||||
Directory.CreateDirectory(logPath);
|
||||
if (!logPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
logPath = logPath += Path.DirectorySeparatorChar;
|
||||
// set environment variable for Serilog configuration
|
||||
Environment.SetEnvironmentVariable("LOG_PATH", logPath);
|
||||
|
||||
@@ -58,7 +67,7 @@ public class Program
|
||||
.ReadFrom.Services(services)
|
||||
.Enrich.FromLogContext();
|
||||
});
|
||||
|
||||
string? aa = builder.Configuration.GetValue<string>("LOG_PATH");
|
||||
WebApplication app = builder.Build();
|
||||
|
||||
app.UseSerilogRequestLogging();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
@@ -20,7 +21,7 @@
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "${LOG_PATH}/lumina_api_.log",
|
||||
"path": "%LOG_PATH%lumina_api_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
|
||||
"retainedFileCountLimit": 7,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# This stage is used when running from VS in fast mode (Default for Debug configuration)
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
RUN mkdir /logs && chown -R app:app /logs
|
||||
USER app
|
||||
WORKDIR /app
|
||||
EXPOSE 5012
|
||||
EXPOSE 7112
|
||||
|
||||
|
||||
# ==== Stage 1: Build stage
|
||||
@@ -41,9 +41,7 @@ WORKDIR /app
|
||||
|
||||
COPY --from=publish /app/publish .
|
||||
ENV ASPNETCORE_HTTP_PORTS=5012
|
||||
ENV ASPNETCORE_HTTPS_PORTS=7112
|
||||
EXPOSE 5012
|
||||
EXPOSE 7112
|
||||
ENTRYPOINT ["dotnet", "Lumina.Presentation.Web.dll"]
|
||||
|
||||
# to build this Docker image, run the following command from the root of the project (location of the .sln file):
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<PackageReference Include="Polly" Version="8.4.1" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
@@ -31,10 +32,18 @@ public class Program
|
||||
// determine log path based on environment
|
||||
string logPath;
|
||||
if (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true")
|
||||
{
|
||||
logPath = Environment.GetEnvironmentVariable("LOG_PATH") ?? "/logs"; // use docker volume path
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.ListenAnyIP(5012); // HTTP only
|
||||
});
|
||||
}
|
||||
else
|
||||
logPath = Path.Combine(AppContext.BaseDirectory, "logs"); // use local binary path
|
||||
Directory.CreateDirectory(logPath);
|
||||
if (!logPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
logPath = logPath += Path.DirectorySeparatorChar;
|
||||
// set environment variable for Serilog configuration
|
||||
Environment.SetEnvironmentVariable("LOG_PATH", logPath);
|
||||
|
||||
@@ -50,7 +59,7 @@ public class Program
|
||||
app.UseSerilogRequestLogging();
|
||||
|
||||
// configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
if (!app.Environment.IsDevelopment() && Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") != "true")
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
"commandName": "Docker",
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTPS_PORTS": "7112",
|
||||
"ASPNETCORE_HTTP_PORTS": "5012"
|
||||
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
@@ -22,7 +23,7 @@
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "${LOG_PATH}/lumina_web_.log",
|
||||
"path": "%LOG_PATH%lumina_web_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
|
||||
"retainedFileCountLimit": 7,
|
||||
|
||||
Reference in new issue
Block a user