Laravel-log-viewer: Deleting log file in use can be dangerous

Created on 19 Jul 2017  ·  8Comments  ·  Source: rap2hpoutre/laravel-log-viewer

Deleting a log file that is currently in used can be fatal. In my case it caused my artisan service to crash. It would be better if the log file was blanked instead of deleted.

php[591]: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/laravel/storage/logs/laravel-2017-07-18.log" could not be opened: failed to open stream

Most helpful comment

May I suggest a new button that will save/rename the old log file and start a new one (create a blank file)? That would be great for backup purposes.

All 8 comments

I think Laravel creates a new one if it doesn't exists, right?

It may do such a check on first run. It is not doing such a check if it is deleted while artisan is accessing it.

Ok, thank you for contributing! I'm sorry about that crash! (and sorry for my late answer).

IMO, blanking the file is a bit weird (as a user you asked for "deleteting", and it just blanked something). And it will polluate the list of file on the left menu. Still, I understand your need. So I don't know what to do... Any thought?

You can blank the log file if it is the current day. Crashing servers is worse than weird behaviour. The weird behaviour can be justified in documentation.

May I suggest a new button that will save/rename the old log file and start a new one (create a blank file)? That would be great for backup purposes.

Available in v0.17.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

judgej picture judgej  ·  9Comments

raksa picture raksa  ·  3Comments

serdarsaygili picture serdarsaygili  ·  11Comments

avesgit picture avesgit  ·  7Comments

mstaack picture mstaack  ·  6Comments