14 Commits

Author SHA1 Message Date
5843e9efa8 feat(logging): enable NLog only in non-development environments 2025-07-22 18:08:52 +02:00
Developer 02
6ade388cd7 Enhance logging configuration in Program.cs
Initialized logging by clearing providers, setting minimum
level to Trace, and configuring NLog as the logging provider.
2025-05-09 23:20:27 +02:00
Developer 02
23e73aae19 IISProfile aktualisieren 2025-04-08 15:30:21 +02:00
Developer 02
23d73e0671 gitignore aktualisiert 2025-04-08 15:29:26 +02:00
Developer 02
72b1c58b72 chore: Aktualisierung der Ziel-Frameworks in der Projektdatei
Geänderte `DigitalData.Gateway.csproj` zur Unterstützung mehrerer
Ziel-Frameworks: `net7.0`, `net8.0` und `net9.0`. Diese
verbessert die Kompatibilität und Flexibilität des Projekts.
2025-04-08 10:53:23 +02:00
Developer 02
4173c3d96a Aktualisierung der Ocelot-Paketversion in der Projektdatei
Die Projektdatei `DigitalData.Gateway.csproj` wurde geändert, um das `Ocelot`-Paket von Version `22.0.1` auf `23.4.3` zu aktualisieren. Außerdem wurde eine kleine Formatierungsänderung am `<Project>`-Tag vorgenommen, der nun ein nicht sichtbares Zeichen am Anfang der Zeile enthält.
2025-04-08 10:50:49 +02:00
Developer 02
8a8f77c4d5 chore: port aktualisiert. 2025-03-24 14:55:35 +01:00
Developer 02
08e3cdddb0 chore: IIS-Profil zu git hinzufügen, um es für Zweige anpassen zu können 2025-03-11 17:14:07 +01:00
Developer 02
e1bd477753 refactor(ocelet.json): konfiguriert 2025-03-11 17:08:53 +01:00
Developer 02
174338af5d Refaktor: Aktualisierung der Endpunktzuordnung auf moderne Syntax zur verbesserten Klarheit 2025-03-11 16:55:34 +01:00
Developer 02
e3be4f5e6f chore(ocelet.Development): Anordnen von Ports und Authentifizierungsendpunkten. 2025-03-11 16:46:35 +01:00
Developer 02
cbd3accf72 feat: Logging für unerwartete Ausnahmen hinzugefügt, um eine bessere Fehlerverfolgung und Problemlösung zu gewährleisten. 2025-03-10 15:42:22 +01:00
Developer 02
d108978b63 feat: NLog hinzugefügt und über App-Einstellungen konfiguriert 2025-03-10 15:00:34 +01:00
Developer 02
6a536e950d feat: Ocelot-Konfigurationsdatei für die Entwicklung hinzugefügt. 2025-03-10 14:33:30 +01:00
8 changed files with 236 additions and 49 deletions

13
.config/dotnet-tools.json Normal file
View File

@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "9.0.3",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.0.0</Version>
@@ -10,7 +10,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ocelot" Version="22.0.1" />
<PackageReference Include="NLog" Version="5.4.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.4.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.4.0" />
<PackageReference Include="Ocelot" Version="23.4.3" />
</ItemGroup>
</Project>

View File

@@ -1,26 +1,46 @@
using NLog;
using NLog.Web;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
var builder = WebApplication.CreateBuilder(args);
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
logger.Info("Logging initialized.");
// Make sure to add the Ocelot configuration file
builder.Configuration.AddJsonFile("ocelot.json");
// Add Ocelot services
builder.Services.AddOcelot();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
// Use Ocelot middleware in an appropriate way
app.UseEndpoints(endpoints =>
try
{
endpoints.MapControllers();
});
var builder = WebApplication.CreateBuilder(args);
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
app.UseOcelot().Wait();
if (!builder.Environment.IsDevelopment())
{
builder.Logging.ClearProviders();
builder.Host.UseNLog();
}
app.Run();
// Make sure to add the Ocelot configuration file
var suffix = builder.Environment.IsDevelopment() ? ".Development" : "";
builder.Configuration.AddJsonFile($"ocelot{suffix}.json");
// Add Ocelot services
builder.Services.AddOcelot();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
// Use Ocelot middleware in an appropriate way
app.MapControllers();
app.UseOcelot().Wait();
app.Run();
}
catch(Exception ex)
{
logger.Error(ex, "Stopped program because of exception.");
throw;
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<WebPublishMethod>Package</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<ExcludeApp_Data>false</ExcludeApp_Data>
<ProjectGuid>329f45bf-4c79-4a7b-9086-d6205617aa42</ProjectGuid>
<DesktopBuildPackageLocation>P:\Install .Net\0 DD - Smart UP\Gateway\WorkFlow\\.zip</DesktopBuildPackageLocation>
<PackageAsSingleFile>true</PackageAsSingleFile>
<DeployIisAppPath>Gateway</DeployIisAppPath>
<_TargetId>IISWebDeployPackage</_TargetId>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@@ -23,7 +23,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"launchUrl": "swagger/index.html",
"applicationUrl": "https://localhost:7052;http://localhost:5028",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"

View File

@@ -5,5 +5,48 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"NLog": {
"throwConfigExceptions": true,
"variables": {
"logDirectory": "E:\\LogFiles\\Digital Data\\workFlow.Gateway",
"logFileNamePrefix": "${shortdate}-workFlow.Gateway"
},
"targets": {
"infoLogs": {
"type": "File",
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
"maxArchiveDays": 30
},
"errorLogs": {
"type": "File",
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
"maxArchiveDays": 30
},
"criticalLogs": {
"type": "File",
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
"maxArchiveDays": 30
}
},
// Trace, Debug, Info, Warn, Error and *Fatal*
"rules": [
{
"logger": "*",
"minLevel": "Info",
"maxLevel": "Warn",
"writeTo": "infoLogs"
},
{
"logger": "*",
"level": "Error",
"writeTo": "errorLogs"
},
{
"logger": "*",
"level": "Fatal",
"writeTo": "criticalLogs"
}
]
}
}

91
ocelot.Development.json Normal file
View File

@@ -0,0 +1,91 @@
{
"Routes": [
{
"DownstreamPathTemplate": "/swagger/{route}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7120
}
],
"UpstreamPathTemplate": "/swagger/{route}",
"UpstreamhttpsMethod": [
"Get"
]
},
{
"DownstreamPathTemplate": "/swagger/{route}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7192
}
],
"UpstreamPathTemplate": "/swagger/auth/{route}",
"UpstreamhttpsMethod": [
"Get"
]
},
{
"DownstreamPathTemplate": "/api/Auth/work-flow?cookie=false",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7192
}
],
"UpstreamPathTemplate": "/api/Auth",
"UpstreamhttpsMethod": [ "Post" ]
},
{
"DownstreamPathTemplate": "/api/Auth/check",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7120
}
],
"UpstreamPathTemplate": "/api/Auth/check",
"UpstreamhttpsMethod": [ "Post" ]
},
{
"DownstreamPathTemplate": "/api/{route}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7120
}
],
"UpstreamPathTemplate": "/api/{route}",
"UpstreamhttpsMethod": [
"Get",
"Post",
"Put",
"Delete"
]
},
{
"DownstreamPathTemplate": "/api/{route}/{id}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7120
}
],
"UpstreamPathTemplate": "/api/{route}{id}",
"UpstreamhttpsMethod": [
"Get",
"Delete"
]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:7052"
}
}

View File

@@ -1,19 +1,5 @@
{
"Routes": [
{
"DownstreamPathTemplate": "/swagger/{route}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 9090
}
],
"UpstreamPathTemplate": "/swagger/auth/{route}",
"UpstreamHttpMethod": [
"Get"
]
},
{
"DownstreamPathTemplate": "/swagger/{route}",
"DownstreamScheme": "http",
@@ -29,22 +15,33 @@
]
},
{
"DownstreamPathTemplate": "/api/Auth/{route}",
"DownstreamPathTemplate": "/swagger/{route}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 8088
"Port": 9090
}
],
"UpstreamPathTemplate": "/api/Auth/{route}",
"UpstreamPathTemplate": "/swagger/auth/{route}",
"UpstreamHttpMethod": [
"Get",
"Post"
"Get"
]
},
{
"DownstreamPathTemplate": "/api/Auth/login/{id}",
"DownstreamPathTemplate": "/api/Auth/work-flow?cookie=false",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 9090
}
],
"UpstreamPathTemplate": "/api/Auth",
"UpstreamHttpMethod": [ "Post" ]
},
{
"DownstreamPathTemplate": "/api/Auth/check",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
@@ -52,10 +49,8 @@
"Port": 8088
}
],
"UpstreamPathTemplate": "/api/Auth/login/{id}",
"UpstreamHttpMethod": [
"Post"
]
"UpstreamPathTemplate": "/api/Auth/check",
"UpstreamHttpMethod": [ "Post" ]
},
{
"DownstreamPathTemplate": "/api/{route}",
@@ -91,6 +86,6 @@
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:7052"
"BaseUrl": "https://localhost:8443"
}
}