2

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 ?

3 Answers 3

3

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

1

With standard configuration, Apache will check daily if the log file size is over 1 MB. If the file does exceed this limit, it will be rotated.

You can learn how to change the default behavior following this tutorial.

1

As Jonathan says, the default size is over 1MB, but you can configure Apache for a bigger size. For example, the Apache Documentation shows:

CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common

This configuration will rotate the logfile whenever it reaches a size of 5 megabytes.

 ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"

This other will rotate the error logfile whenever it reaches a size of 5 megabytes, and the suffix to the logfile name will be created of the form errorlog.YYYY-mm-dd-HH_MM_SS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .