I have a daemon that runs constantly which fills up the log file(development.log or production.log) pretty quickly. What is the best way to delete the log file after certain size or delete the portion before certain day.
I have a daemon that runs constantly which fills up the log file(development.log or
Share
The best way is to set up log rotation, but how you do this is very platform dependent,
so you should add a comment about what you’re using, both for development and production.
For our apps running on Linux, we have a file /etc/logrotate.d/appname for each app,
that looks something like this:
This will move the log into a new file once a day, keeping a compressed backup file for each
of the last 7 days.
If you just want to empty the file without keeping any of the data in it while the daemon is
running, simply do this from a shell:
This will truncate the file to 0 bytes length.