@@ -116,10 +116,11 @@ private static LoggerConfiguration WriteToFile(this LoggerConfiguration loggerCo
116116 if ( useAsync )
117117 {
118118 return loggerConfig . WriteTo . Async ( a =>
119- a . File ( formatter ,
120- logPath ,
121- rollingInterval : RollingInterval . Day )
122- ) ;
119+ a . File ( formatter ,
120+ logPath ,
121+ rollingInterval : RollingInterval . Day ) ,
122+ blockWhenFull : true ,
123+ bufferSize : 20_000 ) ;
123124 }
124125
125126 return loggerConfig . WriteTo . File ( formatter , logPath , rollingInterval : RollingInterval . Day ) ;
@@ -129,59 +130,26 @@ private static LoggerConfiguration FilterOutUnwantedLogs(this LoggerConfiguratio
129130 {
130131 return loggerConfig
131132 . Filter
132- . ByExcluding ( e => e . ShouldExcludeAboveBoardGetLogs ( ) )
133+ . ByExcluding ( e => e . ExcludeOutboxAndMassTransit ( ) )
133134 . Filter
134- . ByExcluding ( e => e . ShouldExcludeHangfireDashboardLogs ( ) )
135- . Filter
136- . ByExcluding ( e => e . ShouldExcludeOutboxDbCommandLogs ( ) )
137- . Filter
138- . ByExcluding ( e => e . ShouldExcludeSwaggerLogs ( ) )
139- . Filter
140- . ByExcluding ( e => e . ShouldExcludeMassTransitHealthCheckLogs ( ) ) ;
141- }
142-
143- private static bool ShouldExcludeAboveBoardGetLogs ( this LogEvent logEvent )
144- {
145- var path = logEvent . Properties . TryGetValue ( "RequestPath" , out var p ) && p is ScalarValue sv
146- ? sv . Value ? . ToString ( )
147- : null ;
148-
149- var method = logEvent . Properties . TryGetValue ( "RequestMethod" , out var m ) && m is ScalarValue mv
150- ? mv . Value ? . ToString ( )
151- : null ;
152-
153- return string . Equals ( method , "GET" , StringComparison . OrdinalIgnoreCase )
154- && path ? . StartsWith ( "/above-board" , StringComparison . OrdinalIgnoreCase ) == true ;
155- }
156-
157- private static bool ShouldExcludeHangfireDashboardLogs ( this LogEvent logEvent )
158- {
159- return logEvent . Properties . TryGetValue ( "RequestPath" , out var requestPathValue )
160- && requestPathValue is ScalarValue requestPath
161- && requestPath . Value
162- ? . ToString ( )
163- ? . Contains ( "/hangfire" ) == true ;
135+ . ByExcluding ( evt =>
136+ {
137+ if ( ! evt . Properties . TryGetValue ( "RequestPath" , out var p ) || p is not ScalarValue sv )
138+ return false ;
139+ var path = sv . Value as string ?? "" ;
140+ return path . StartsWith ( "/swagger" )
141+ || path . StartsWith ( "/hangfire" )
142+ || path . Contains ( "/above-board" )
143+ || path . Contains ( "localhost/auth/is-authenticated.json?api-version=v2" ) ;
144+ } ) ;
164145 }
165146
166- private static bool ShouldExcludeOutboxDbCommandLogs ( this LogEvent logEvent )
147+ private static bool ExcludeOutboxAndMassTransit ( this LogEvent logEvent )
167148 {
168149 var message = logEvent . RenderMessage ( ) ;
169- return message . Contains ( "outbox_messages" , StringComparison . OrdinalIgnoreCase ) ;
170- }
171-
172- private static bool ShouldExcludeSwaggerLogs ( this LogEvent logEvent )
173- {
174- return logEvent . Properties . TryGetValue ( "RequestPath" , out var requestPathValue )
175- && requestPathValue is ScalarValue requestPath
176- && requestPath . Value
177- ? . ToString ( )
178- ? . Contains ( "/swagger" ) == true ;
179- }
180-
181- private static bool ShouldExcludeMassTransitHealthCheckLogs ( this LogEvent logEvent )
182- {
183- var message = logEvent . RenderMessage ( ) ;
184- return message . StartsWith ( "Health check masstransit-bus with status Unhealthy completed after" ) ;
150+ return message . Contains ( "outbox_messages" , StringComparison . OrdinalIgnoreCase ) || message . StartsWith (
151+ "Health check masstransit-bus with status Unhealthy completed after" ,
152+ StringComparison . OrdinalIgnoreCase ) ;
185153 }
186154
187155 private static string GetLogsPath ( this WebApplicationBuilder builder )
@@ -194,5 +162,4 @@ private static string GetLogsPath(this WebApplicationBuilder builder)
194162 var fileName = $ "logs-{ instanceId } -.json";
195163 return Path . Combine ( persistencePath , repoName , envName , "logs" , fileName ) ;
196164 }
197-
198165}
0 commit comments