serilog-sinks-file icon indicating copy to clipboard operation
serilog-sinks-file copied to clipboard

Consider enabling `FileLifecycleHooks` for shared log files

Open nblumhardt opened this issue 5 years ago • 1 comments

Currently, we throw if hooks are specified and shared is true.

This is mostly because it's tricky to use stream wrapping (one of the main use cases) with the atomic-append-based shared file sink, but also because it's unclear how many hooks could be implemented correctly in the synchronization-free world of the atomic-append sink.

When both hooks and shared are set, we could fall back to using the (portable) OS-mutex-based shared file sink. This would be simpler to integrate the hooks into, and we could call the hooks under the mutex to improve chances of writing correct implementations.

nblumhardt avatar Apr 22 '19 21:04 nblumhardt

Hi @nblumhardt is this something can can be supported? currently I need to know the name of the log file inside my ILogEventSink implementation so I use hook the get the file name on OnFileOpened method but also need shared file to be able to copy the file to other location periodically.

currently I'm getting 'File lifecycle hooks are not currently supported for shared log files. Parameter name: hooks' exception

LiorBanai avatar Dec 13 '22 13:12 LiorBanai