I have created a class library for custom logger and register my logger to windows or web application using extension method on IHostBuilder. I want to create "Log" folder (if not exists) in directory were Program.cs file exists. With console application I can create directory using relative path Directory.CreateDirectory(@"......\Logs") and it creates directory in desired location. However when my logger is registered with WebApp it creates directory in "F:\Logs\CsvILogger.csv".
public static IHostBuilder RegisterMyLoggerWithDefaultSettings(this IHostBuilder builder)
{
//How can I get absolute path of program.cs file here with web application?
}
How can I get path to folder where "program.cs" file exists when my logger is registered to WebApplication?