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

Add ability to get the file path of the log file via hooks #191

Closed
augustoproiete opened this issue Nov 9, 2020 · 1 comment · Fixed by #189
Closed

Add ability to get the file path of the log file via hooks #191

augustoproiete opened this issue Nov 9, 2020 · 1 comment · Fixed by #189

Comments

@augustoproiete
Copy link
Member

Over time I've seen a few questions on StackOverflow asking for a feature similar to what's being asked on serilog/serilog#1489 which is the ability to inspect the properties of the sinks configured, at run-time.

That feature is a bigger piece of work that requires design, of course, however in many of those questions, devs were aiming to use such a feature just to get a hold of the path of the file being written by this sink in particular, for different reasons (*).

I propose adding the log file path to the existing OnFileOpened hook, which would allow devs to plug in a hook that captures the file path of every log file written and keep track of the most recent one.

This would provide a workaround for this particular scenario until serilog/serilog#1489 or something similar becomes available.

Also, for consistency, the OnFileDeleting hook already exposes the file path, and I couldn't think of a reason why OnFileOpened wouldn't do the same.


(*) I can remember of a couple of examples where devs would like to know the exact file name (considering the name changes with rolling) in order to do run some activity:

@cocowalla
Copy link
Contributor

I expected there to be some discussion and evolution once hooks hit the stable version and they became more visible, nice to see it happening 😄

The OnFileDeleting hook has the path of the file being deleted, and the scenarios given make sense - I don't know what you think @nblumhardt, but I'm in favour of this change 👍

Only thing I'd add is, to try to avoid churn: aside from filename, is there any other information that might be required? (I can't personally think of any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants