Skip to content

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

Closed
@augustoproiete

Description

@augustoproiete

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions