Logging Options in the Cisco IOS
For any network administrator, it is a necessary to know how to properly use logging. The Cisco IOS offers a great many options for logging. To help you know them well, we will discuss how to configure logging, how to view the log and its status, and list three common errors when it comes to logging.
The logging command in Global Configuration Mode and the show logging command in Privileged Mode are two simple but powerful tools to configure and show all Cisco IOS logging options. Let's take a closer look.
Configure logging in the Cisco IOS
When configuring logging, the most important command to know is the logging command, used when in Global Configuration Mode. Here's an example of this command and its options.
In order to help you know these options in a good way, let’s look at the most common ones.
You can configure the router to send buffered logging of its events to the memory. (Rebooting the router will lose all events stored in the buffered log.) Here's an example:
Router(config)# logging buffered 16384
You can also send the router's events to a syslog server. This is an external server running on your network. Most likely, the syslog server is running on a Linux or Windows server. Because it's external to the router, there's an added benefit: It preserves events even if the router loses power. A syslog server also provides for centralized logging for all network devices.
To configure syslog logging, all you need to do is use the logging command and the hostname or IP address of the syslog server. So, to configure your Cisco device to use a syslog server, use the following command:
Router(config)# logging 10.1.1.1
The Cisco IOS enables logging to the console, monitor, and syslog by default. But there's a catch: There's no syslog host configured, so that output goes nowhere.
There are eight different logging levels.
The default level for console, monitor, and syslog is debugging. The logging on command is the default. To disable all logging, use the no logging on command.
By default, the router logs anything at the level of debugging and greater. That means that logging occurs from level 7 (debugging) up to level 0 (emergencies). If you want to par down what the system logs, use something like the logging console notifications command.
In addition, the router doesn't enable logging to the system buffer by default. That's why you must use the logging buffered command to enable it.
View the status of logging and the logging itself
To view the status of your logging as well as the local buffered log, use the show loggingcommand. Here's an example:
Note that this router has enabled syslog logging and is sending it to host 10.1.1.1. In addition, console logging is at the debugging level, and the setting for local buffered logging is 10,000,000 bytes.
Three common logging errors
Logging can be frustrating at times. To help prevent some of that frustration, let's look at three common errors.
Not setting the terminal to monitor logging
If you Telnet into a router and can't see some of the logging you're expecting, check to see if you've set your terminal to monitor the logging. You can enable this with the terminal monitor command. To disable it, use the terminal no monitor command.
To determine whether you've enabled monitoring, use the show terminal command, and look for the following:
Capabilities: Receives Logging Output
If you see this, you're monitoring logging output. If it returns none for capabilities, then the monitoring is off.
Using the incorrect logging level
If you can't see logging output, you should also check whether you've set the level correctly. For example, if you've set the console logging to emergencies but you're running debugging, you won't see any debugging output on the console.
To determine the set level, use the show logging command. Keep in mind that you need to set the level to a higher number to see all levels below it. For example, setting logging at debugging shows you every other level.
In addition, make sure you match the type of logging that you want to see with the level you're configuring. If you configure monitor logging to debug but you're on the console and you've set it to informational, you won't see the debug output on the console.
Displaying the incorrect time and date in logs
You may see log messages that don't exhibit the correct date and time. There are a variety of options to control the date and time that appear on logging output (either to the screen or to the buffer). To control this, use the following command:
Router(config)# service timestamps debug ?
datetime Timestamp with date and time
uptime Timestamp with system uptime
More Notes: Remember that many problems require some kind of historical log to help find a solution. That's why it's important to make sure you've properly configured logging so you can use your logs to see the past.
Reference from http://www.techrepublic.com/