290
Saving logs to the log file
By default, the log file feature saves logs from the log file buffer to the log file every 24 hours. You can
adjust the saving interval or manually save logs to the log file. After saving logs to the log file, the
system clears the log file buffer.
The device supports multiple log files. Each log file has a maximum capacity. The log files are named
as
logfile1.log
,
logfile2.log
, and so on.
When
logfile1.log
is full, the system compresses
logfile1.log
as
logfile1.log.gz
and creates a new
log file named
logfile2.log
. The process repeats until the last log file is full.
After the last log file is full, the device repeats the following process:
1.
The device locates the oldest compressed log file
logfileX.log.gz
and creates a new file using
the same name (
logfileX.log
).
2.
When
logfileX.log
is full, the device compresses the log file as
logfileX.log.gz
to replace the
existing file
logfileX.log.gz
.
As a best practice, back up the log files regularly to avoid loss of important logs.
You can enable log file overwrite-protection to stop the device from saving new logs when the last log
file is full or the storage device runs out of space.
To save logs to the log file:
Step
Command
Remarks
1.
Enter system view.
system-view
N/A
2.
Enable the information
center.
info-center enable
By default, the information center
is enabled.
3.
Enable the log file feature.
info-center logfile enable
By default, the log file feature is
enabled.
4.
(Optional.) Enable log file
overwrite-protection.
info-center logfile
overwrite-protection
[
all-port-powerdown
]
By default, log file
overwrite-protection is disabled.
This feature is supported only in
FIPS mode.
5.
(Optional.) Set the maximum
size for the log file.
info-center logfile size-quota
size
The default setting is 10 MB.
To ensure normal operation, set
the
size
argument to a value
between 1 MB and 10 MB.
6.
(Optional.) Specify the
directory to save the log file.
info-center logfile directory
dir-name
The default log file directory is
flash:/logfile
.
(In standalone mode.) This
command cannot survive a reboot
or an active/standby switchover.
(In IRF mode.) This command
cannot survive an IRF reboot or a
global active/standby switchover
in an IRF fabric.
7.
Save the logs in the log file
buffer to the log file.
•
Configure the interval to
perform the save operation:
info-center logfile
frequency
freq-sec
•
Manually save the logs in the
log file buffer to the log file:
logfile save
The default saving interval is
86400 seconds.
The
logfile save
command is
available in any view.