public static void SetupDatabase(DbContextOptionsBuilder options) { options .UseNpgsql(EnvVariable.Get(EnvVariables._DbConnectionString)) .UseSnakeCaseNamingConvention(); #if DEBUG options.LogTo(Console.WriteLine); #endif }
public static void Setup(WebHostBuilderContext _, LoggerConfiguration config) { var elasticUrl = EnvVariable.Get(EnvVariables._ElasticUrl); LogEventLevel logLevel = LogEventLevel.Warning; if (Enum.TryParse(EnvVariable.TryGet(EnvVariables._LogLevel), true, out LogEventLevel level)) { logLevel = level; } config .MinimumLevel.Is(logLevel) .Enrich.FromLogContext() .WriteTo.Console() .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(elasticUrl)) { IndexFormat = $"{RoleNames._AuthorityService}-logs-{DateTime.UtcNow:yyyy-MM}" }); }