@@ -199,7 +199,6 @@ public static LoggerConfiguration File(
199199 /// <param name="encoding">Character encoding used to write the text file. The default is UTF-8 without BOM.</param>
200200 /// <param name="hooks">Optionally enables hooking into log file lifecycle events.</param>
201201 /// <returns>Configuration object allowing method chaining.</returns>
202- /// <remarks>The file will be written using the UTF-8 character set.</remarks>
203202 public static LoggerConfiguration File (
204203 this LoggerSinkConfiguration sinkConfiguration ,
205204 ITextFormatter formatter ,
@@ -235,20 +234,54 @@ public static LoggerConfiguration File(
235234 /// the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".</param>
236235 /// <returns>Configuration object allowing method chaining.</returns>
237236 /// <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>
238269 public static LoggerConfiguration File (
239270 this LoggerAuditSinkConfiguration sinkConfiguration ,
240271 string path ,
241272 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
242273 string outputTemplate = DefaultOutputTemplate ,
243274 IFormatProvider formatProvider = null ,
244- LoggingLevelSwitch levelSwitch = null )
275+ LoggingLevelSwitch levelSwitch = null ,
276+ Encoding encoding = null ,
277+ FileLifecycleHooks hooks = null )
245278 {
246279 if ( sinkConfiguration == null ) throw new ArgumentNullException ( nameof ( sinkConfiguration ) ) ;
247280 if ( path == null ) throw new ArgumentNullException ( nameof ( path ) ) ;
248281 if ( outputTemplate == null ) throw new ArgumentNullException ( nameof ( outputTemplate ) ) ;
249282
250283 var formatter = new MessageTemplateTextFormatter ( outputTemplate , formatProvider ) ;
251- return File ( sinkConfiguration , formatter , path , restrictedToMinimumLevel , levelSwitch ) ;
284+ return File ( sinkConfiguration , formatter , path , restrictedToMinimumLevel , levelSwitch , encoding , hooks ) ;
252285 }
253286
254287 /// <summary>
@@ -267,15 +300,53 @@ public static LoggerConfiguration File(
267300 /// to be changed at runtime.</param>
268301 /// <returns>Configuration object allowing method chaining.</returns>
269302 /// <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>
270335 public static LoggerConfiguration File (
271336 this LoggerAuditSinkConfiguration sinkConfiguration ,
272337 ITextFormatter formatter ,
273338 string path ,
274339 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
275- LoggingLevelSwitch levelSwitch = null )
340+ LoggingLevelSwitch levelSwitch = null ,
341+ Encoding encoding = null ,
342+ FileLifecycleHooks hooks = null )
276343 {
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+
277348 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 ) ;
279350 }
280351
281352 static LoggerConfiguration ConfigureFile (
0 commit comments