Log File Rotation
Log rotation is important to maintain the stability of the device, because the larger log files are difficult to manipulate and file system would run out of space. The solution to this common problem is log file rotation.
Log rotation is scheduled to happen for every 5 minutes, here the log file size is used as the condition to perform rotation.
Log rotate operation creates a backup of the current log file, and clears the current log file content. Also these rotated log files are compressed to save disk space. Excluding the current log file, four backup files are maintained in the system, and the older logs are removed as part of the rotation operation.
Default log file /var/log/messages rotated, if the size is greater than 100 MB. The following are the rotated log files generated in the path /var/log
root@host:/var/log# ls messages*
messages messages.1 messages.2.gz messages.3.gz messages.4.gz
Manually configured log file /log/LOG1 gets rotated, if its size is greater than configured size. Here LOG1 is the manually configured using the command logging logfile <filename> and the log file size in bytes can be configured using the command logging logfile LOG1 <severity> size <4096-419430400>
(config)#logging logfile LOG1 7 size 4096
Here configured logging file /log/LOG1 is rotated if the size is greater than 4096 bytes. The following are the rotated log files generated in the path /log
root@host:/log# ls LOG*
LOG1 LOG1.1 LOG1.2.gz LOG1.3.gz LOG1.4.gz
Last modified date: 10/19/2023