Changing the Size of a Logging File
Problem
You need to change the size of your logfiles.
Solution
You can change the default size of all logfiles with the following command:
[edit system] aviva@router1# set syslog archive size 256k
You can also change the size of an individual logfile:
[edit system] aviva@router1# set syslog log file messages archive size 512k
Discussion
The default maximum size of logging files is 128 KB. You might want to increase the maximum if the files are filling up too quickly, and you might want to make the files smaller if you are running out of hard disk space on the router. All JUNOS logging files are the same size. The first command in this recipe shows how to change the default file size for all syslog files, here changing it to 256 KB. The second command changes the file size just for the messages logging file.
Depending on how much system logging information you are collecting and what errors and problems might be occurring on the router, a logging file can reach its maximum size quickly, in just a few hours, or over the course of several days or weeks. Instead of discarding the oldest information, the JUNOS software renames the full file and compresses it, and continues collecting new logging information in the original, now empty file. For the messages file we created, when it fills up, it is renamed to messages.0.gz. When the messages file fills up a second time, messages.0.gz is renamed to messages.1.gz and the new file is compressed and renamed to messages.0.gz. This continues until there are 10 files (the default value):
aviva@router1> show log messages? Possible completions: Name of log file messages Size: 59682, Last changed: Mar 09 15:13:53 messages.0.gz Size: 8886, Last changed: Mar 03 04:00:00 messages.1.gz Size: 7820, Last changed: Feb 22 12:00:00 messages.10.gz Size: 7834, Last changed: Feb 10 04:00:00 messages.2.gz Size: 9189, Last changed: Feb 18 04:00:00 messages.3.gz Size: 7115, Last changed: Feb 17 21:00:01 messages.4.gz Size: 7191, Last changed: Feb 17 09:00:00 messages.5.gz Size: 7579, Last changed: Feb 16 22:00:00 messages.6.gz Size: 7241, Last changed: Feb 16 10:00:01 messages.7.gz Size: 9059, Last changed: Feb 15 23:00:01 messages.8.gz Size: 17682, Last changed: Feb 15 11:00:01 messages.9.gz Size: 14807, Last changed: Feb 15 04:00:01
After the tenth file, the file contents are overwritten. If you want to save the older contents of the logging message files, you can increase the number of files that the software saves. When you change the number of logging files, it affects all the logging files maintained by the router. You can't change this value for an individual logging file.
[edit system] aviva@router1# set syslog archive file 20
Keep an eye on hard disk usage to make sure there is enough storage for all logfiles. The logfiles are in the /var/log directory, which is mounted on the /var partition:
aviva@router1> show system storage | match ad Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1a 77M 39M 32M 55% / /dev/ad0s1e 12M 16K 11M 0% /config /dev/ad1s1f 9.4G 1.2G 7.4G 14% /var
When space gets low, clear or delete any old or unnecessary logfiles or move them to a file server.
If you are logging to a remote server and are running out of disk space on the server, either change how many messages you log to the remote server by changing the facilities or levels you log to the remote server, or reconfigure the remote server to roll over its logfiles faster.