title: How do I rotate my Rails 5 logs?
body: <p>I'm running Rails 5 on Ubuntu 14.04.  Is there a way to rotate my logs without relying on the Linux logrotate system?  I have this set up ...</p>
  
  <pre><code>myuser@myapp:~$ cat /etc/logrotate.d/myapp
  /home/rails/myapp/log/*.log {
    daily
    missingok
    rotate 2
    compress
    delaycompress
    notifempty
    copytruncate
  }
  </code></pre>
  
  <p>but yet my logs never rotate.  Behold how bloated they are ...</p>
  
  <pre><code>myuser@myapp:~$ ls -al /home/rails/myapp/log/
  total 3958356
  drwxr-xr-x  2 rails rails       4096 Jul  3 22:31 .
  drwxr-xr-x 15 rails rails       4096 Sep 21 17:21 ..
  -rw-rw-r--  1 rails rails          0 Jun 22 10:22 development.log
  -rw-rw-r--  1 rails rails      14960 Jun  1 22:39 development.log.1
  -rw-rw-r--  1 rails rails          0 Oct 22  2016 .keep
  -rw-r--r--  1 rails rails  198362787 Oct 31 16:28 production.log
  -rw-r--r--  1 rails rails    8615654 Jul  3 22:31 production.log.1
  -rw-r--r--  1 rails rails  640621243 Jun 29 13:16 production.log.2.gz
  -rw-rw-r--  1 rails rails 2856792698 Oct 31 17:12 sidekiq.log
  -rw-rw-r--  1 rails rails  348853619 Jul  3 22:31 sidekiq.log.1
  -rw-rw-r--  1 rails rails          0 Jul  3 22:31 test.log
  -rw-rw-r--  1 rails rails      54246 Jul  3 22:31 test.log.1
  </code></pre>
  
  <p>Is there another way to get the logs rotated or is there a way to fix the configuration I have included?</p>
  
  <p><b>Edit:</b> Here's the cron script that's set</p>
  
  <pre><code>myuser@myapp:~$ cat /etc/cron.daily/logrotate
  #!/bin/sh
  
  # Clean non existent log file entries from status file
  cd /var/lib/logrotate
  test -e status || touch status
  head -1 status &gt; status.clean
  sed 's/"//g' status | while read logfile date
  do
      [ -e "$logfile" ] &amp;&amp; echo "\"$logfile\" $date"
  done &gt;&gt; status.clean
  mv status.clean status
  
  test -x /usr/sbin/logrotate || exit 0
  /usr/sbin/logrotate /etc/logrotate.conf
  </code></pre>
  
  <p><b>Edit:</b> Per the comment I tried adding this to my config/environment/production.rb file ...</p>
  
  <pre><code>config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, 50 * 1024 * 1024)
  </code></pre>
  
  <p>but the logs get ever bigger without being rotated.</p>