1. static string LogFilePath(string LogEvent) => $@"{AppContext.BaseDirectory}00_Logs\{LogEvent}\log.log";
    2. Log.Logger = new LoggerConfiguration()
    3. #if DEBUG
    4. .MinimumLevel.Debug()
    5. #else
    6. .MinimumLevel.Information()
    7. #endif
    8. .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
    9. .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
    10. .Enrich.FromLogContext()
    11. .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Debug).WriteTo.Async(c => c.File(LogFilePath("Debug"), rollingInterval: RollingInterval.Day)))
    12. .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Information).WriteTo.Async(c => c.File(LogFilePath("Information"), rollingInterval: RollingInterval.Day)))
    13. .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Warning).WriteTo.Async(c => c.File(LogFilePath("Warning"), rollingInterval: RollingInterval.Day)))
    14. .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Error).WriteTo.Async(c => c.File(LogFilePath("Error"), rollingInterval: RollingInterval.Day)))
    15. .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Fatal).WriteTo.Async(c => c.File(LogFilePath("Fatal"), rollingInterval: RollingInterval.Day)))
    16. #if DEBUG
    17. .WriteTo.Async(c => c.Console())
    18. #else
    19. //.Enrich.WithProperty("app", "XXXX")
    20. //.WriteTo.GrafanaLoki(configuration["App:LokiUrl"])
    21. #endif
    22. .CreateLogger();