Skip to content

Instantly share code, notes, and snippets.

@johncarney
Last active March 1, 2024 22:14
Show Gist options
  • Save johncarney/fd72402a0c8119eb48f5 to your computer and use it in GitHub Desktop.
Save johncarney/fd72402a0c8119eb48f5 to your computer and use it in GitHub Desktop.
Example newsyslog configuration for rotating Rails log files on Mac OS X.
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/Users/your-username/path-your-rails-project/log/*.log your-username:staff 644 4 * $D0 GJ
# NOTES
#
# Place file in /etc/newsyslog.d
# '$D0' under 'when' tells newsyslog to rotate logs daily at midnight.
# Alternatively you could use '24' for 'when', which would specify "every 24 hours"
# '*' under 'size' specifies that logs should be rotated regardless of their size.
# 'G' under 'flags' tells newsyslog that the 'logfilename' is a pattern and it should rotate all log files matching the pattern.
# 'J' under 'flags' specifies that rotated logs should be compressed using bzip2.
@unmultimedio
Copy link

Awesome, thanks!
I guess you use this in development environment?

@dennislysenko
Copy link

Have you ever noticed your rails starts failing to write to logs after they are rotated? Wondering if this has to do with the pid_file option being left out.

@jeffrey008
Copy link

Hello, does anyone know how to let Rails point to newly rotated logfile? Rails still logs to old log file after rotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment