feat: Logging für unerwartete Ausnahmen hinzugefügt, um eine bessere Fehlerverfolgung und Problemlösung zu gewährleisten.
This commit is contained in:
parent
d108978b63
commit
cbd3accf72
49
Program.cs
49
Program.cs
@ -6,27 +6,36 @@ using Ocelot.Middleware;
|
|||||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||||
logger.Info("Logging initialized.");
|
logger.Info("Logging initialized.");
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
try
|
||||||
|
|
||||||
// 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.UseEndpoints(endpoints =>
|
|
||||||
{
|
{
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// 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.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseOcelot().Wait();
|
app.UseOcelot().Wait();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex, "Stopped program because of exception.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user