Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.04k stars 1.9k forks source link

Overwriting a log file? #1912

Open phrfpeixoto opened 2 months ago

phrfpeixoto commented 2 months ago

Hello there!

I'm using monolog 2.9 and I'm looking for an easy way to overwrite a log file. My use case is that I have processes that run in frequent intervals, and I want to be able to capture both the full log for all operations, as well as the "last log" for the latest iteration.

I fussed into the StreamHandler, and it it always fopens the file in append more. I tried creating a custom handler, but it seems that visibility for some required methods is restricted to private.

phrfpeixoto commented 2 months ago

I've created a quick PR #1913 to allow the user to configure this. Let me know if it helps