Skip to content

Allow FileLifecycleHooks to change the length of the stream #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
augustoproiete opened this issue Nov 4, 2020 · 0 comments
Closed

Allow FileLifecycleHooks to change the length of the stream #186

augustoproiete opened this issue Nov 4, 2020 · 0 comments

Comments

@augustoproiete
Copy link
Member

augustoproiete commented Nov 4, 2020

Currently files are opened with FileMode.Append, which prevents FileLifecycleHooks from modifying the size of the stream when implementing an OnFileOpened hook.

In addition, when fileSizeLimitBytes is set, the stream is wrapped via WriteCountingStream which does not implement SetLength.

Changing the size of the stream can be useful in a few scenarios, such as:


  • Calling SetLength with fileSizeLimitBytes to null throws System.IO.IOException: Unable to truncate data that previously existed in a file opened in Append mode

  • Calling SetLength with fileSizeLimitBytes to any number throws System.NotSupportedException: Specified method is not supported

augustoproiete added a commit to augustoproiete-forks/serilog--serilog-sinks-file that referenced this issue Nov 4, 2020
augustoproiete added a commit to augustoproiete-forks/serilog--serilog-sinks-file that referenced this issue Nov 4, 2020
augustoproiete added a commit to augustoproiete-forks/serilog--serilog-sinks-file that referenced this issue Nov 9, 2020
augustoproiete added a commit to augustoproiete-forks/serilog--serilog-sinks-file that referenced this issue Nov 12, 2020
augustoproiete added a commit to augustoproiete-forks/serilog--serilog-sinks-file that referenced this issue Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant