Skip to content
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

Support for reading compressed files? #45

Closed
Numpsy opened this issue Jul 5, 2020 · 6 comments
Closed

Support for reading compressed files? #45

Numpsy opened this issue Jul 5, 2020 · 6 comments
Labels
enhancement New feature or request In progress

Comments

@Numpsy
Copy link
Contributor

Numpsy commented Jul 5, 2020

Hi,

I'm not sure if this idea is in scope for the library, or indeed just for Serilog bit (none-Serilog specific), but:

I recently had a look at some Serilog add-ons that compress the log files at various points (e.g. https://github.com/cocowalla/serilog-sinks-file-gzip, https://github.com/cocowalla/serilog-sinks-file-archive), and it came to mind that it could possibly be useful to be able to read the .gz compressed log files without having to unpack them first?

Doing so could possibly be as simple as wrapping the FileStreams in GzipStreams before reading the contents, though I do have a slight recollection that the .NET 4.7 version of GZipStream would only read the first chunk of the file when given a .gz file that contains multiple pieces (which was fixed in the .NET Core version). I haven't tested it though, this is just a thought at the moment.

Any thoughts?

@LiorBanai
Copy link
Member

Very interesting and worth checking. Especially for users the are using compressed files daily. The task of unpacking could get very tiresome after some time.

@LiorBanai LiorBanai added the enhancement New feature or request label Jul 6, 2020
@LiorBanai LiorBanai assigned LiorBanai and unassigned LiorBanai Jul 6, 2020
@LiorBanai
Copy link
Member

LiorBanai commented Jul 6, 2020

just summary:
One option (as you wrote) is to just unzip the content into temp folder, read all files and then delete them.
Another option, and more interesting, is to read directly the file stream and process it in memory (which is preferable to save IO).

It could be at the library level or the extension. Need to think about it a little :)

@LiorBanai
Copy link
Member

@Numpsy do you have an example gz file by any chance? I have added small implementation but don't have nominal archive to test it on.

@Numpsy
Copy link
Contributor Author

Numpsy commented Jul 19, 2020

This is a trivial clef/gz file that I created with a test app and the Serilog File and File.GZip sinks:

SerilogTest.Clef.gz

(I don't think there should be any difference to a plain .clef file compressed to a .gz using gzip/7-zip etc though)

@LiorBanai
Copy link
Member

Thanks :)
so I have added in memory parsing.

image

in case the data provider does not support compressed file I'm falling back to local unziping (and adding to the file open dialog the extensions):
image

@Numpsy
Copy link
Contributor Author

Numpsy commented Jul 20, 2020

Thanks, looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request In progress
Projects
None yet
Development

No branches or pull requests

2 participants