18

Is it possible to write an arbitrary line of text to the log of a Cisco IOS 12.x device?

I should like to be able to put in markers when fetching configs via TFTP and I would like to be able to have log lines á la

 May 30 14:14:00.000: %CONFIG-REMARK: Halfway through the script! Now on to SomethingThatMightFail!
 May 30 14:14:05.000: %CONFIG-REMARK: SomethingThatMightFail didn't fail! Woo! Continuing!
Jan
  • 623
  • 6
  • 15

3 Answers3

22

You can use the send log command:

switch#send log Halfway through the script!

gives my on a Catalyst 3750 with IOS 12.2

May 31 16:36:18: %SYS-2-LOGMSG: Message from 1(name): Halfway through the script!

and with IOS 15.0:

May 31 16:38:08: %SYS-7-USERLOG_DEBUG: Message from tty1(user id: name): Halfway through the script!
Stefan
  • 3,374
  • 6
  • 32
  • 49
3

The syntax for sending a test syslog from a Cisco device depends on software version; here are the command syntaxes I've seen, including, where available, the option for setting syslog severity:

Most Cisco platforms, if running IOS 12.2(58) and higher:

send log [severity] [text to send]
Eg:
send log
send log   This message will go to my syslog server.
send log 5 This message will go to my syslog server.

Most Cisco platforms, if running IOS 12.2(52) and lower:

send log [text to send]
Eg:
send log
send log   This message will go to my syslog server.

ASR1000 running IOS-XE 03.01.00, which is sourced from IOS 15.0(1):

send log [severity [text to send]]
Eg:
send log
send log 5 This message will go to my syslog server.

ASR1000 running other IOS-XE versions (including 02.04.03 from IOS 12.2(33), 03.04.04 from IOS 15.1(3), 03.14.00 from IOS 15.5(1)):

send log [severity] [text to send]
Eg:
send log
send log   This message will go to my syslog server.
send log 5 This message will go to my syslog server.

ASR9000 running IOS-XR 4.2.1 and higher:

log <text to send>
Eg:
log This message will go to my syslog server.

WS-C6513 running IOS 12.2(18): No equivalent command; you need to use another method to generate a syslog message. For example, the following should generate 5 syslogs (interface up, line protocol up, interface down, line protocol down, and configuration changed), depending on your logging settings. Leave out the 2 interface commands to generate just the one generic configuration-changed syslog.

config t
interface loopback601
no interface loopback601
end
Joel L
  • 31
  • 2
2

Assuming you're using TCL EEM you can use action_syslog.

bigmstone
  • 1,847
  • 13
  • 17