Skip to content

Commit a3b88e9

Browse files
committed
updated serilog
1 parent d5f4bf7 commit a3b88e9

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Pandatech.CleanArchitecture.Infrastructure/Extensions/SerilogExtension.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Pandatech.CleanArchitecture.Core.Extensions;
77
using Pandatech.CleanArchitecture.Infrastructure.Helpers;
88
using Serilog;
9+
using Serilog.Configuration;
910
using Serilog.Events;
1011

1112
namespace Pandatech.CleanArchitecture.Infrastructure.Extensions;
@@ -38,31 +39,35 @@ private static LoggerConfiguration ConfigureEnvironmentSpecificSettings(this Log
3839
{
3940
if (builder.Environment.IsLocal())
4041
{
41-
loggerConfig.WriteTo.Console();
42+
loggerConfig
43+
.WriteTo
44+
.Console();
4245
}
4346
else if (builder.Environment.IsDevelopment())
4447
{
4548
loggerConfig
4649
.WriteTo
4750
.Console()
4851
.WriteTo
49-
.File(new EcsTextFormatter(),
50-
builder.GetLogsPath(),
51-
rollingInterval: RollingInterval.Day,
52-
shared: true);
52+
.File(builder);
5353
}
5454
else
5555
{
5656
loggerConfig
5757
.WriteTo
58-
.File(new EcsTextFormatter(),
59-
builder.GetLogsPath(),
60-
rollingInterval: RollingInterval.Day,
61-
shared: true);
58+
.File(builder);
6259
}
6360

6461
return loggerConfig;
6562
}
63+
64+
private static void File(this LoggerSinkConfiguration loggerConfig, WebApplicationBuilder builder)
65+
{
66+
loggerConfig
67+
.File(new EcsTextFormatter(),
68+
builder.GetLogsPath(),
69+
rollingInterval: RollingInterval.Day);
70+
}
6671

6772
private static LoggerConfiguration FilterOutUnwantedLogs(this LoggerConfiguration loggerConfig)
6873
{

0 commit comments

Comments
 (0)