Skip to content

Commit 1b860c3

Browse files
committed
Update
1 parent 5f8f59f commit 1b860c3

5 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/plugins/SerilogTest/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/logs

src/plugins/SerilogTest/Controllers/LogTestController.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ public IEnumerable<WeatherForecast> LogWarning()
3030
var arr = Enumerable.Range(1, 5)
3131
.Select(
3232
index =>
33-
new WeatherForecast
33+
{
34+
var dateTime = DateTime.Now.AddDays(index);
35+
return new WeatherForecast
3436
{
35-
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
37+
Date = DateOnly.FromDateTime(dateTime),
38+
DateTime = dateTime,
39+
DateTimeOffset = DateTimeOffset.UtcNow,
3640
TemperatureC = Random.Shared.Next(-20, 55),
3741
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
38-
})
42+
};
43+
})
3944
.ToArray();
4045

4146
_logger.LogWarning("result is {@Arr}", arr);

src/plugins/SerilogTest/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static LoggerConfiguration ConfigureLogger(LoggerConfiguration configuration)
100100
.Enrich
101101
.WithExceptionDetails(
102102
new DestructuringOptionsBuilder().WithDefaultDestructurers()
103-
//.WithRootName("x")
103+
.WithIgnoreStackTraceAndTargetSiteExceptionFilter()
104104
.WithDestructurers([new DbUpdateExceptionDestructurer()]));
105105
}
106106
}

src/plugins/SerilogTest/WeatherForecast.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ namespace SerilogTest;
22

33
public class WeatherForecast
44
{
5+
6+
#region Properties
7+
58
public DateOnly Date { get; set; }
69

10+
public DateTime DateTime { get; set; }
11+
12+
public DateTimeOffset DateTimeOffset { get; set; }
13+
14+
public string? Summary { get; set; }
15+
716
public int TemperatureC { get; set; }
817

918
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1019

11-
public string? Summary { get; set; }
20+
#endregion
21+
1222
}

src/plugins/SerilogTest/appsettings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
{
3434
"Name": "Console",
3535
"Args": {
36-
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {NewLine}{Message:lj}{NewLine}{Properties:lj}{NewLine}"
36+
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {NewLine}{Message:lj}{NewLine}{Properties:lj}{NewLine}{Exception}{NewLine}"
3737
}
3838
},
3939
{
4040
"Name": "File",
4141
"Args": {
4242
"path": "logs/log-.txt",
43-
"rollingInterval": "Minute",
43+
"rollingInterval": "Day",
4444
"rollOnFileSizeLimit": true,
4545
"fileSizeLimitBytes": 104857600,
4646
"retainedFileCountLimit": 14,
@@ -52,7 +52,7 @@
5252
"Args": {
5353
"restrictedToMinimumLevel": "Error",
5454
"path": "logs/log-error-.txt",
55-
"rollingInterval": "Minute",
55+
"rollingInterval": "Day",
5656
"rollOnFileSizeLimit": true,
5757
"fileSizeLimitBytes": 104857600,
5858
"retainedFileCountLimit": 14,

0 commit comments

Comments
 (0)