How to control error_log file size

apache-2.2log-fileslogging

I can see multiple error_log files on my Apache Server.
Example: error_log, error_log.1, error_log.2, error_log.3, error_log.4 ..

I think initially single file is created with name error_log. Then after some limit on single file all contents of error_log file will be moved to error_log.1 and new errors will be inserted in error_log.

I want to understand what is limit on file size OR when server decide to create new error file for error_log. I guess this must configurable ??

Also, I noticed that file size of all files mentioned in example are different.

Please help me to understand How this process works ?

Best Answer

This tool called logrotate, which is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files.

Each log file may be handled daily, weekly, monthly, or when it grows too large. With this tool you keep logs longer with less disk space. for more details you can refer: http://linuxers.org/howto/howto-use-logrotate-manage-log-files