@@ -199,7 +199,6 @@ public static LoggerConfiguration File(
199
199
/// <param name="encoding">Character encoding used to write the text file. The default is UTF-8 without BOM.</param>
200
200
/// <param name="hooks">Optionally enables hooking into log file lifecycle events.</param>
201
201
/// <returns>Configuration object allowing method chaining.</returns>
202
- /// <remarks>The file will be written using the UTF-8 character set.</remarks>
203
202
public static LoggerConfiguration File (
204
203
this LoggerSinkConfiguration sinkConfiguration ,
205
204
ITextFormatter formatter ,
@@ -235,20 +234,54 @@ public static LoggerConfiguration File(
235
234
/// the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".</param>
236
235
/// <returns>Configuration object allowing method chaining.</returns>
237
236
/// <remarks>The file will be written using the UTF-8 character set.</remarks>
237
+ [ Obsolete ( "New code should not be compiled against this obsolete overload" ) , EditorBrowsable ( EditorBrowsableState . Never ) ]
238
+ public static LoggerConfiguration File (
239
+ this LoggerAuditSinkConfiguration sinkConfiguration ,
240
+ string path ,
241
+ LogEventLevel restrictedToMinimumLevel ,
242
+ string outputTemplate ,
243
+ IFormatProvider formatProvider ,
244
+ LoggingLevelSwitch levelSwitch )
245
+ {
246
+ if ( sinkConfiguration == null ) throw new ArgumentNullException ( nameof ( sinkConfiguration ) ) ;
247
+ if ( path == null ) throw new ArgumentNullException ( nameof ( path ) ) ;
248
+ if ( outputTemplate == null ) throw new ArgumentNullException ( nameof ( outputTemplate ) ) ;
249
+
250
+ var formatter = new MessageTemplateTextFormatter ( outputTemplate , formatProvider ) ;
251
+ return File ( sinkConfiguration , formatter , path , restrictedToMinimumLevel , levelSwitch , null ) ;
252
+ }
253
+
254
+ /// <summary>
255
+ /// Write log events to the specified file.
256
+ /// </summary>
257
+ /// <param name="sinkConfiguration">Logger sink configuration.</param>
258
+ /// <param name="path">Path to the file.</param>
259
+ /// <param name="restrictedToMinimumLevel">The minimum level for
260
+ /// events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param>
261
+ /// <param name="levelSwitch">A switch allowing the pass-through minimum level
262
+ /// to be changed at runtime.</param>
263
+ /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
264
+ /// <param name="outputTemplate">A message template describing the format used to write to the sink.
265
+ /// the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".</param>
266
+ /// <param name="encoding">Character encoding used to write the text file. The default is UTF-8 without BOM.</param>
267
+ /// <param name="hooks">Optionally enables hooking into log file lifecycle events.</param>
268
+ /// <returns>Configuration object allowing method chaining.</returns>
238
269
public static LoggerConfiguration File (
239
270
this LoggerAuditSinkConfiguration sinkConfiguration ,
240
271
string path ,
241
272
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
242
273
string outputTemplate = DefaultOutputTemplate ,
243
274
IFormatProvider formatProvider = null ,
244
- LoggingLevelSwitch levelSwitch = null )
275
+ LoggingLevelSwitch levelSwitch = null ,
276
+ Encoding encoding = null ,
277
+ FileLifecycleHooks hooks = null )
245
278
{
246
279
if ( sinkConfiguration == null ) throw new ArgumentNullException ( nameof ( sinkConfiguration ) ) ;
247
280
if ( path == null ) throw new ArgumentNullException ( nameof ( path ) ) ;
248
281
if ( outputTemplate == null ) throw new ArgumentNullException ( nameof ( outputTemplate ) ) ;
249
282
250
283
var formatter = new MessageTemplateTextFormatter ( outputTemplate , formatProvider ) ;
251
- return File ( sinkConfiguration , formatter , path , restrictedToMinimumLevel , levelSwitch ) ;
284
+ return File ( sinkConfiguration , formatter , path , restrictedToMinimumLevel , levelSwitch , encoding , hooks ) ;
252
285
}
253
286
254
287
/// <summary>
@@ -267,15 +300,53 @@ public static LoggerConfiguration File(
267
300
/// to be changed at runtime.</param>
268
301
/// <returns>Configuration object allowing method chaining.</returns>
269
302
/// <remarks>The file will be written using the UTF-8 character set.</remarks>
303
+ [ Obsolete ( "New code should not be compiled against this obsolete overload" ) , EditorBrowsable ( EditorBrowsableState . Never ) ]
304
+ public static LoggerConfiguration File (
305
+ this LoggerAuditSinkConfiguration sinkConfiguration ,
306
+ ITextFormatter formatter ,
307
+ string path ,
308
+ LogEventLevel restrictedToMinimumLevel ,
309
+ LoggingLevelSwitch levelSwitch )
310
+ {
311
+ if ( sinkConfiguration == null ) throw new ArgumentNullException ( nameof ( sinkConfiguration ) ) ;
312
+ if ( formatter == null ) throw new ArgumentNullException ( nameof ( formatter ) ) ;
313
+ if ( path == null ) throw new ArgumentNullException ( nameof ( path ) ) ;
314
+
315
+ return File ( sinkConfiguration , formatter , path , restrictedToMinimumLevel , levelSwitch , null ) ;
316
+ }
317
+
318
+ /// <summary>
319
+ /// Write log events to the specified file.
320
+ /// </summary>
321
+ /// <param name="sinkConfiguration">Logger sink configuration.</param>
322
+ /// <param name="formatter">A formatter, such as <see cref="JsonFormatter"/>, to convert the log events into
323
+ /// text for the file. If control of regular text formatting is required, use the other
324
+ /// overload of <see cref="File(LoggerAuditSinkConfiguration, string, LogEventLevel, string, IFormatProvider, LoggingLevelSwitch, Encoding, FileLifecycleHooks)"/>
325
+ /// and specify the outputTemplate parameter instead.
326
+ /// </param>
327
+ /// <param name="path">Path to the file.</param>
328
+ /// <param name="restrictedToMinimumLevel">The minimum level for
329
+ /// events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param>
330
+ /// <param name="levelSwitch">A switch allowing the pass-through minimum level
331
+ /// to be changed at runtime.</param>
332
+ /// <param name="encoding">Character encoding used to write the text file. The default is UTF-8 without BOM.</param>
333
+ /// <param name="hooks">Optionally enables hooking into log file lifecycle events.</param>
334
+ /// <returns>Configuration object allowing method chaining.</returns>
270
335
public static LoggerConfiguration File (
271
336
this LoggerAuditSinkConfiguration sinkConfiguration ,
272
337
ITextFormatter formatter ,
273
338
string path ,
274
339
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
275
- LoggingLevelSwitch levelSwitch = null )
340
+ LoggingLevelSwitch levelSwitch = null ,
341
+ Encoding encoding = null ,
342
+ FileLifecycleHooks hooks = null )
276
343
{
344
+ if ( sinkConfiguration == null ) throw new ArgumentNullException ( nameof ( sinkConfiguration ) ) ;
345
+ if ( formatter == null ) throw new ArgumentNullException ( nameof ( formatter ) ) ;
346
+ if ( path == null ) throw new ArgumentNullException ( nameof ( path ) ) ;
347
+
277
348
return ConfigureFile ( sinkConfiguration . Sink , formatter , path , restrictedToMinimumLevel , null , levelSwitch , false , true ,
278
- false , null , null , RollingInterval . Infinite , false , null , null ) ;
349
+ false , null , encoding , RollingInterval . Infinite , false , null , hooks ) ;
279
350
}
280
351
281
352
static LoggerConfiguration ConfigureFile (
0 commit comments