Last Updated: February 25, 2016
·
308
· pftg

Auto-cleanup development logs on OS X with ease

While you have been working on a projects for a long period of time you may find that a large amount of your disk space is being taken up by your development logs.

OS X comes with newsyslog utility to handle log files.

Add /etc/newsyslog.d/io.user.dev.conf configuration with body:

# logfilename [owner:group] mode count size when  flags [/pid_file] [sig_num]
/Users/u/dev/**/*/*.log       666 0 5120 * GN
/Users/u/Library/**/*/*.log   666 0 5120 * GN

This configuration will setup newsyslog to trim log files with size more than 5MB in all subfolders unders /Users/user/dev/.

To verify that it works and simulate a rotation, you can run this command: newsyslog -nvr