-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging-json-formatter.cs
More file actions
executable file
·40 lines (36 loc) · 1.32 KB
/
logging-json-formatter.cs
File metadata and controls
executable file
·40 lines (36 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Microsoft.Extensions.Logging.Console
- ConsoleFormatterNames.Json ConsoleLoggerExtensions.AddJsonConsole()
- ConsoleFormatterNames.Simple ConsoleLoggerExtensions.AddSimpleConsole()
- ConsoleFormatterNames.Systemd ConsoleLoggerExtensions.AddSystemdConsole()
// Program.cs
builder.Logging.AddJsonConsole(options =>
{
options.UseUtcTimestamp = true;
});
builder.Logging.AddConsole(options => options.FormatterName = ConsoleFormatterNames.Simple);
// appsettings.json (alternativa)
{
"Logging": {
"Console": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"FormatterName": "json",
"FormatterOptions": {
"Timestamp": "09:08:33 ",
"EventId": 0,
"LogLevel": "Information",
"Category": "Microsoft.Hosting.Lifetime",
"Message": "Now listening on: https://localhost:5001",
"State": {
"Message": "Now listening on: https://localhost:5001",
"address": "https://localhost:5001",
"{OriginalFormat}": "Now listening on: {address}"
}
}
}
},
"AllowedHosts": "*"
}