File tree 2 files changed +6
-9
lines changed
src/Serilog.Sinks.File/Sinks/File
2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ namespace Serilog.Sinks.File
19
19
{
20
20
/// <summary>
21
21
/// Enables hooking into log file lifecycle events.
22
+ /// Hooks run synchronously and therefore may affect responsiveness of the application if long operations are performed.
22
23
/// </summary>
23
24
public abstract class FileLifecycleHooks
24
25
{
@@ -37,13 +38,10 @@ public abstract class FileLifecycleHooks
37
38
public virtual Stream OnFileOpened ( Stream underlyingStream , Encoding encoding ) => underlyingStream ;
38
39
39
40
/// <summary>
40
- /// Method called on log files that were marked as obsolete (old) and would be deleted.
41
- /// This can be used to copy old logs to archive location or send to backup server
41
+ /// Called before an obsolete (rolling) log file is deleted.
42
+ /// This can be used to copy old logs to an archive location or send to a backup server.
42
43
/// </summary>
43
- /// <remarks>
44
- /// Executing long synchronous operation may affect responsiveness of application
45
- /// </remarks>
46
- /// <param name="fullPath">Log file full path</param>
47
- public virtual void OnFileRemoving ( string fullPath ) { }
44
+ /// <param name="path">The full path to the file being deleted.</param>
45
+ public virtual void OnFileDeleting ( string path ) { }
48
46
}
49
47
}
Original file line number Diff line number Diff line change @@ -199,8 +199,7 @@ void ApplyRetentionPolicy(string currentFilePath)
199
199
var fullPath = Path . Combine ( _roller . LogFileDirectory , obsolete ) ;
200
200
try
201
201
{
202
- if ( _hooks != null ) _hooks . OnFileRemoving ( fullPath ) ;
203
-
202
+ _hooks ? . OnFileDeleting ( fullPath ) ;
204
203
System . IO . File . Delete ( fullPath ) ;
205
204
}
206
205
catch ( Exception ex )
You can’t perform that action at this time.
0 commit comments