Logging 101

Configuring Logging

Logging messages generated by the router are sent to the logging process. It controls the distribution of the messages to various destinations. If the logging process is off, then only the console receives log messages. To enable logging, use:
1
R(config)# logging on
Copied!
Without this command only the console will receive logs.

Logging Destination

1
R(config)# logging buffered [SIZE]
2
! Logs messages to an internal buffer.
3
R(config)# logging HOST-IP [LEVEL]
4
! Logs messages to a syslog server host.
5
R(config)# logging trap LEVEL
6
! Must be enabled in order to log messages to Syslog Host
7
R(config)# logging file FILENAME [MAX-SIZE [MIN-SIZE]] [LEVEL]
8
! Logs messages to a file
9
R(config)# logging console
10
! Logs messages to con0 output
11
R(config)# logging monitor
12
! Logs messages to vty output
Copied!
By default, debug information only appears on the console terminal. To show them on the current terminal, use:
1
Router# terminal monitor
Copied!
By default, unsolicited debug information will interrupt solicited display information. Using synchronous logging, unsolicited debug information will only be displayed after the solicited information is displayed.
1
R(config-line)# logging synchronous [level LEVEL | all] [limit BUFFERS]
Copied!

Timestamps and Line Numbers

By default, log messages are not time-stamped, but tou can set timestamping using:
1
R(config)# service timestamps log { uptime | datetime [msec] [localtime] [show-timezone]}
2
! uptime – time since last reboot
3
! datetime - Current Datetime in UTC
4
! localtime – Shows the time in the configured timezone
5
! msec – adds milisec to the timestamp
6
! show-timezone – adds timezone to the time
Copied!
Separate settings can be configure for debug messages:
1
R(config)# service timestamps log { uptime | datetime [msec] [localtime] [show-timezone]}
Copied!
You can also enable the services for adding sequence numbers to the log:
1
R(config)# service sequence-numbers
Copied!

Error message level

1
R(config)# logging {console|monitor|trap} LEVEL
Copied!
Level
Keyword
Description
Syslog
0
Emergencies
System unusable
LOG_EMERG
1
Alerts
Immediate action needed
LOG_ALERT
2
Critical
Critical conditions
LOG_CRIT
3
Errors
Error conditions
LOG_ERR
4
Warnings
Warning conditions
LOG_WARNING
5
Notifications
Normal but significant conditions
LOG_NOTICE
6
Informational
Informational messages
LOG_INFO
7
Debugging
Debugging messages
LOG_DEBUG

Additional settings

1
! Add an origin Identifier:
2
R(config)# logging origin-id {hostname|ip|ipv6|string STRING}
3
! Rate limit log messages per second:
4
R(config)# logging rate-limit [all|console] MESSAGES-PER-SEC [except LEVEL]
5
! Set the source of syslog messages:
6
R(config)# logging source-interface INTERFACE
7
! Log user information when a user uses the enable command:
8
R(config)# logging userinfo
Copied!

Logging configuration changes

1
R(config)# archive
2
R(config-archive)# log config
3
R(config-archive-log-cfg)# logging enable
4
R(config-archive-log-cfg)# logging size SIZE
5
R(config-archive-log-cfg)# hidekeys
6
! Suppresses the display of passwords
7
R(config-archive-log-cfg)# notify syslog
8
! Enables sending of configuration changes to a syslog server
Copied!

Monitoring Logs

To see the buffered logs, use:
1
R# show logging [count|history]
Copied!
To see the archive logs, use:
1
R# show archive log config [all|user USER]
Copied!
Last modified 24d ago