Contents

Introduction

Prerequisites

Requirements

Components Used

Background Information

Configure

Configuration example

Verify

Troubleshoot

Related Information

Introduction

This document describes how to enable system logging messages in order to save output to the router's flash disk.

Prerequisites

Requirements

- Logging  messages to an internal buffer must be enabled using logging buffered Command Line Interface (CLI)

- Enough free space on the flash disk in order to store the desired number of logging files

Note: It is recommended to set the system clock to the correct date and time and verify router’s Central Processing Unit (CPU) utilization before and after feature activation.

Components Used

This document is not restricted to any specific software and hardware versions.

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.

Background Information

Typically, logging messages (warnings, error and/or debugs etc.) are stored in a router's memory buffer (DRAM); when the buffer is full, older messages are overwritten by new messages. This poses an issue  when trying to capture debugs for an intermittent issue or during high traffic. Huge buffer size configuration can not alwayshelp as the buffer can get filled and overwritten quickly during verbose debugging. Using persistent logging allows to write logged messages to  file(s) on router's flash disk. The advantage is unlike memory buffer (DRAM) contents these files persist when the router reboots (DRAM contents are erased during a reboot.)

Configure

Step 1. Enable system logging message to a local buffer:

logging buffered[buffer-size|level]

Step 2. Enable logging messages in order to write from the memory buffer to router's flash disk:

logging persistent [ batchbatch-size ] { filesizelogging-file-size } [ immediate ] { notify } [ protected ] { sizefilesystem-size } [ thresholdthreshold-capacity [ alert ] ] [ url { disk0:/directory | disk1:/directory } ]

Note: Amount of disk storage allocated (filesystem-size) and size of individual logging file (logging-file-size) are specified in bytes.

Step 3. Enable desired debugs [optional]

Note: The filename format is log_YYYYMMDD-HHMMSS (For example: log_20130927-112427)

Configuration example

Router(config)#logging buffer 20000000 debugging

Router(config)#logging persistent url flash0:/MYDEBUGS size 104857600 filesize 5242880

Above command creates a directory called MYDEBUGS on the router's disk 0 and allocates 104857600 bytes (100MB) disk space for log messages and specifies an individual file size of 5MB.

Caution: When the allocation threshold is exceeded, the oldest log file in the directory is deleted to make room for new system logging messages.

Copy Logging Messages to an external device

Individual files written to the flash disk can be transferred to external File Transfer Protocol /Trivial File Transfer Protocol (FTP/TFTP) server by use of the IOS copy command:

Router# copy disk0:/MYDEBUG/log* ftp://user:passwd@<ftp_server_ip_address>/

Router# copy disk0:/MYDEBUG/log* tftp://<tftp_server_ip_address>/

Verify

Use this section to confirm that your configuration works properly.

Router#show logging

Syslog logging: enabled (110977 messages dropped, 17 messages rate-limited, 0 flushes, 0 overruns, xml disabled, filtering disabled)

Console logging: disabled

Monitor logging: disabled

Buffer logging:  level debugging, 31667 messages logged, xml disabled,

filtering disabled

Exception Logging: size (8192 bytes)

Count and timestamp logging messages: disabled

Persistent logging: enabled, url flash0:/MYDEBUGS, disk space 104857600 bytes, file size 5242880 bytes, batch size 4096 bytes

Router#dir flash0:MYDEBUGS

Directory of flash0:/MYDEBUGS/

223  -rw-     5239168  Sep 27 2013 11:31:16 -04:00  log_20130927-112427

224  -rw-     5239631  Sep 27 2013 11:38:06 -04:00  log_20130927-113117

225  -rw-     3500757  Sep 27 2013 11:42:40 -04:00  log_20130927-113807

Troubleshoot

There is currently no specific troubleshooting information available for this configuration.

TheCisco CLI Analyzer(registeredcustomers only) supports certainshowcommands. Use the Cisco CLI Analyzer in order to view an analysis ofshowcommand output.

Note: Refer toImportant Information on Debug Commandsbefore you usedebugcommands.

Related Information

- SYSLOG Writing to Flash

- Technical Support & Documentation - Cisco Systems