Skip to content

Commit 4b882e0

Browse files
committed
Security Improvement
1 parent 1f93e69 commit 4b882e0

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

Gnoss.BackgroundTask.CacheRefresh/Program.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,16 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
3737
Host.CreateDefaultBuilder(args)
3838
.UseWindowsService() //Windows
3939
.UseSystemd() //Linux
40+
.ConfigureAppConfiguration((hostContext, config) =>
41+
{
42+
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
43+
config.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
44+
})
4045
.ConfigureServices((hostContext, services) =>
4146
{
4247
IConfiguration configuration = hostContext.Configuration;
43-
ILoggerFactory loggerFactory =
44-
LoggerFactory.Create(builder =>
45-
{
46-
builder.AddConfiguration(configuration.GetSection("Logging"));
47-
builder.AddSimpleConsole(options =>
48-
{
49-
options.IncludeScopes = true;
50-
options.SingleLine = true;
51-
options.TimestampFormat = "yyyy-MM-dd HH:mm:ss ";
52-
options.UseUtcTimestamp = true;
53-
});
54-
});
55-
services.AddSingleton(loggerFactory);
56-
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
48+
LoggingService.ConfigurarLogging(services, configuration);
49+
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
5750
services.AddScoped(typeof(UtilTelemetry));
5851
services.AddScoped(typeof(Usuario));
5952
services.AddScoped(typeof(UtilPeticion));
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
{
22
"Logging": {
33
"LogLevel": {
4+
"Default": "Error",
5+
"Microsoft": "Error",
6+
"Microsoft.Hosting.Lifetime": "Error"
7+
}
8+
},
9+
"Serilog": {
10+
"MinimumLevel": {
411
"Default": "Information",
5-
"Microsoft": "Warning",
6-
"Microsoft.Hosting.Lifetime": "Information"
12+
"Override": {
13+
"Microsoft": "Warning",
14+
"Microsoft.Hosting.Lifetime": "Information"
15+
}
716
}
817
}
9-
}
18+
}

0 commit comments

Comments
 (0)