public static void ConfigureSerilog(HostBuilderContext context, LoggerConfiguration config) { if (context.Configuration.GetSection(_sectionName).Exists()) { config.ReadFrom.Configuration(context.Configuration, _sectionName); } else { string dir = GetDefaultLogPath("log"); string logsPath = context.Configuration.GetValue <string>(_logsPathProperty, null); if (!string.IsNullOrWhiteSpace(logsPath)) { dir = Path.Combine(Environment.ExpandEnvironmentVariables(logsPath), GetLogFileName("log")); } config.AddSharedConfiguration(); config.AddFileDefaults(dir); } }