We are currently running a Dynamicweb 10 solution on Dynamicweb Cloud and are having trouble getting custom logs to write to the file system (/Files/System/Log) in our Staging and Production environments.
The Goal:
We have implemented a custom GeoRoutingMiddleware to handle market-specific redirects. We want to log these routing decisions so we can monitor them in staging and production.
The Implementation:
Currently, we are using the Dynamicweb.Logging.LogManager. to generate these logs. We test-fired the logger in both Program.cs and our middleware:
In Program.cs:
// ... [Standard DW10 app building] ...
app.UseMiddleware<
app.UseDynamicweb();
// Test logs
var geoLogger = Dynamicweb.Logging.LogManager.
geoLogger.Debug("Debug - Application started.");
geoLogger.Info("Info - Application started.");
geoLogger.Warn("Warn - Application started.");
geoLogger.Error("Error - Application started");
app.Run();
In GeoRoutingMiddleware.cs:
// ...
private DwLogger Logger => _logger ??= Dynamicweb.Logging.LogManager.
public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Path != "/")
{
await _next(context);
return;
}
Logger.Warn("Market routing middleware handling requests received to root");
// ... [Routing Logic] ...
}
The Issue:
Despite these calls, absolutely no log files are being generated under /Files/System/Log in our cloud environments.
Our Questions:
-
Is "
LogManager.Current"fully supported for file logging in DW10 Cloud? Or does this approach require additional manual configuration to write to/Files/System/Log? -
Should we be using standard ASP.NET Core Dependency Injection (
ILogger<GeoRoutingMiddleware>) instead? If so, how do we configure the native ASP.NET Core logger to output to the /Files/System/Logfolder so it can be viewed in the DW Insights UI?
Any guidance or documentation on the best practice for writing persistent custom logs in DW10 Cloud would be greatly appreciated.