Exemple #1
0
        public static void SetupDatabase(DbContextOptionsBuilder options)
        {
            options
            .UseNpgsql(EnvVariable.Get(EnvVariables._DbConnectionString))
            .UseSnakeCaseNamingConvention();

#if DEBUG
            options.LogTo(Console.WriteLine);
#endif
        }
Exemple #2
0
        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}"
            });
        }