How to configure rotation for custom application logs

We can use logrotate utility for rotating the custom application logs.

In-order to achieve this, a configuration need to be add under logrotate for each application.

Step1: Login to the server via ssh as root.

Step2: Change the location to logrotate config folder.

#cd /etc/logrotate.d/

Step3: Create a new file with the name of the application itself.

Step4: Save the following lines to the newly created file.

logfile-path {
create 0644 root root
rotate 10

The variable logfile-path need to be replaced with the exact path for the application log file.

Also note that here in example daily log rotation is configured. This can be configured to daily or weekly or even monthly.

This sample configuration will keep 10 files and older files other than this will be removed.

That's all…

Leave a Reply