Skip to content

Commit e0bf81b

Browse files
committed
Move serilog sink usage to code
1 parent da5c698 commit e0bf81b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

App/Api/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using Api.Setup;
23
using Azure.Identity;
34
using Serilog;
@@ -9,8 +10,11 @@
910
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
1011
.Build();
1112

13+
const string logFormat = "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message:lj}{NewLine}{Exception}";
14+
1215
Log.Logger = new LoggerConfiguration()
1316
.ReadFrom.Configuration(config)
17+
.WriteTo.Console(outputTemplate: logFormat, formatProvider: CultureInfo.InvariantCulture)
1418
.CreateLogger();
1519

1620
var builder = WebApplication.CreateBuilder(args);

App/Api/appsettings.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,13 @@
77
}
88
},
99
"Serilog": {
10-
"Using": ["Serilog.Sinks.Console"],
1110
"MinimumLevel": {
1211
"Default": "Information",
1312
"Override": {
1413
"Microsoft": "Information",
1514
"Microsoft.AspNetCore": "Warning"
1615
}
17-
},
18-
"WriteTo": [
19-
{
20-
"Name": "Console",
21-
"Args": {
22-
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message:lj}{NewLine}{Exception}"
23-
}
24-
}
25-
]
16+
}
2617
},
2718
"AllowedHosts": "*"
2819
}

0 commit comments

Comments
 (0)