Rotate Log Files in Rails Application with LogRotate in Ubuntu

Application Log Files Rotation with Logrotate in Ubuntu

We all know that when you hire Ruby on Rails web development services for a web app, the application server is processing the requests, it creates log files. Few weeks ago, one of my application server crashed several times. By looking into server logs, we found that log files consume too much space in the server.

However if the log files keep growing they can outrun the disk space and there might be chances of your application server crashes. Now how to resolve this issue ? Let’s see the solution I have preferred for Log Rotation.

Linux is providing a standard utility called Logrotate which has all the features you typically need!

Let’s see how to work with Logrotate library to rotate our Rails application’s log files.

Let’s see what each line actually means.

There are so many  other options available in logrotate which Ruby on Rails developers can use based on their needs. You will find all options here.

Now let’s see how to run log rotation to check that it is working properly.

As we have mentioned daily option, the following output is of everyday rotation. You can specify weekly and monthly options also.

Congratulations, you’re set!  Happy log rotating 🙂

Related posts

Pros and Cons of React Native App Development

byShardul Bhatt
4 years ago

Vim for Ruby on Rails Development  -  Match made in Heaven

byParth Barot
8 years ago

Python: Perfect Web Framework choice for Startups

byParth Barot
4 years ago
Exit mobile version