-
Notifications
You must be signed in to change notification settings - Fork 33
[Feature] File header #42
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
Comments
Interesting scenario - thanks for the note. Will need to have a think about how this would fit in. |
Thanks for considering it. A file created event might also be nice for some other use cases e.g. to run some code that archives the previous log file. It would be nice if the event contained some info like the name of the new file the reason why there's a new file (e.g. old file got too big or because a time limit was reached). |
File headers are very useful sometimes for long running services when the first log could be already deleted or if service was restarted multiple times. |
Is there any way to add headers in txt file generated by serilog ? |
In our latest projects we required to mimic IIS logs, to achieve this we needed to create a header in every rolling file. We've forked from "serilog-sinks-rollingfile" and added this functionality, would you be interested in considering this changeset? |
will you please send me some details or repository path for code base?
…On Tue, Jun 12, 2018 at 2:18 PM jeremyellul ***@***.***> wrote:
In our latest projects we required to mimic IIS logs, to achieve this we
needed to create a header in every rolling file. We've forked from
"serilog-sinks-rollingfile" and added this functionality, would be be
interested in considering this changeset?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#42 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMtX4bUdXicfMUwBjYyP02pgqlVmeX0lks5t74BIgaJpZM4LDUKD>
.
|
Can you give some details . |
This is now available via serilog/serilog-sinks-file#80 - let me know if you need any help/pointers wiring it up (no docs just yet :-)) |
@strohhut @bikash7411 @jeremyellul I've just published a NuGet package, Serilog.Sinks.File.Header, which contains a header-writing implementation based on the supporting work merged into |
This is really great and it has my 10 thumbs up. I'm really interested in using it. However, I have a different scenario where all my Serilog's sinks are configured through a json file. It is possible to use the new package while reading the settings from a json file? I know this scenario is very complicated but just want to hear your thoughts about that. |
@emiliovmq Yes, I usually use JSON configuration too - it's not totally obvious how to configure hooks though, so I have a section in the readme in the GitHub repo 😄 |
Thank you, sir. Actually, it was my fault for not reading the readme where
examples are provided. On the other hand, I posted another question
regarding the package, please, see below>
@cocowalla <https://github.com/cocowalla> is there any support at
Serilog.Sinks.File.Header for DI. Let me explain myself. We have a
requirement that dictates that for every log we generate we should add to
the beginning of the file the version information of our APIs. As you might
expect, I'm reading the version information from the assemblies attributes
using reflection (which is a very expensive process). To not incur in this
very costly process (for every file event and for my internal requests), I
only read the version info once (the first time it is requested),
registering it with the DI container and resolve it for every subsequent
request or event. l would like to inject the version info into the header
writer. Is there any simple workaround for this?
Again, thanks for your help and this great new feature. Looking forward to
the new release.
…On Mon, May 6, 2019 at 12:43 PM cocowalla ***@***.***> wrote:
@emiliovmq <https://github.com/emiliovmq> Yes, I usually use JSON
configuration too - it's not totally obvious how to configure hooks though,
so I have a section in the readme
<https://github.com/cocowalla/serilog-sinks-file-header/blob/master/README.md>
in the GitHub repo 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#42 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG4Y6B7M6CMHOGU2CKJJTHDPUBNZVANCNFSM4CYNIKBQ>
.
|
@emiliovmq no exactly support for DI, but yes, you can supply a factory method ( You would typically configure this static factory method once, during startup, when you're configuring logging and other infrastructure concerns. |
I want to use CSV format when logging so every generated file should have the fields as first line.
I think it would be nice if there was a file created event that allows to insert text.
The text was updated successfully, but these errors were encountered: