Asp.Net-Core-Inventory-Order-Management-System icon indicating copy to clipboard operation
Asp.Net-Core-Inventory-Order-Management-System copied to clipboard

Potential issue: Logs folder creation may fail on restricted environments

Open ZohaiAli opened this issue 5 months ago • 0 comments

The application tries to create a logs directory at wwwroot/app_data/logs on startup:

var logPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "app_data", "logs");
if (!Directory.Exists(logPath))
{
    Directory.CreateDirectory(logPath);
}

Potential problems:

If the application runs in restricted environments (e.g., IIS with limited permissions, Docker container), Directory.CreateDirectory may fail.

This could cause the application to crash before Serilog initializes.

Suggested fix / improvement:

Wrap directory creation in try-catch and log any exceptions.

Consider making log path configurable in appsettings.json instead of hardcoding under wwwroot.

ZohaiAli avatar Oct 14 '25 09:10 ZohaiAli