AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 641919
Accepted
user2964971
user2964971
Asked: 2014-11-05 07:05:07 +0800 CST2014-11-05 07:05:07 +0800 CST 2014-11-05 07:05:07 +0800 CST

Cisco IOS:仅在命令行上记录调试消息

  • 772

我想要一个安静的命令行,例如(config)# no logging console原因。不过,我想使用# debug命令。在我看来,这# debug取决于系统日志级别 7。所以我不能有一个安静的 CLI 并同时阅读调试消息。

有解决方法吗?

Host(config)#logging ?
  Hostname or A.B.C.D  IP address of the logging host
  buffered             Set buffered logging parameters
  buginf               Enable buginf logging for debugging
  cns-events           Set CNS Event logging level
  console              Set console logging parameters
  count                Count every log message and timestamp last occurrence
  discriminator        Create or modify a message discriminator
  dmvpn                DMVPN Configuration
  esm                  Set ESM filter restrictions
  exception            Limit size of exception flush output
  facility             Facility parameter for syslog messages
  filter               Specify logging filter
  history              Configure syslog history table
  host                 Set syslog server IP address and parameters
  message-counter      Configure log message to include certain counter value 
  monitor              Set terminal line (monitor) logging parameters
  on                   Enable logging to all enabled destinations
  origin-id            Add origin ID to syslog messages
  persistent           Set persistent logging parameters
  queue-limit          Set logger message queue size
  rate-limit           Set messages per second limit
  reload               Set reload logging level
  server-arp           Enable sending ARP requests for syslog servers when first configured
  source-interface     Specify interface for source address in logging transactions
  trap                 Set syslog server logging level
  userinfo             Enable logging of user info on privileged mode enabling

Host(config)#logging console ?
  <0-7>          Logging severity level
  alerts         Immediate action needed           (severity=1)
  critical       Critical conditions               (severity=2)
  debugging      Debugging messages                (severity=7)
  discriminator  Establish MD-Console association
  emergencies    System is unusable                (severity=0)
  errors         Error conditions                  (severity=3)
  filtered       Enable filtered logging
  guaranteed     Guarantee console messages
  informational  Informational messages            (severity=6)
  notifications  Normal but significant conditions (severity=5)
  warnings       Warning conditions                (severity=4)
  xml            Enable logging in XML
  <cr>

使用cpt_fink解决方案的示例:

之后logging console critical和logging buffered 64000 debug之后:clear log_Host

Host#show log
Syslog logging: enabled (12 messages dropped, 0 messages rate-limited,
                0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.



No Inactive Message Discriminator.


    Console logging: level critical, 20 messages logged, xml disabled,
                     filtering disabled
    Monitor logging: level debugging, 0 messages logged, xml disabled,
                     filtering disabled
    Buffer logging:  level debugging, 4 messages logged, xml disabled,
                     filtering disabled
    Logging Exception size (4096 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled

No active filter modules.

ESM: 0 messages dropped

    Trap logging: level informational, 36 message lines logged

Log Buffer (64000 bytes):
Host#
Host#
Host#debug ip icmp
ICMP packet debugging is on
Host#
Host#
Host#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Host(config)#   
Host(config)#interface fastethernet0/1
Host(config-if)#
Host(config-if)#ip address 192.168.0.1 255.255.255.0
Host(config-if)#
Host(config-if)#no shut
Host(config-if)#end
Host#
Host#
Host#show log
Syslog logging: enabled (12 messages dropped, 0 messages rate-limited,
                0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.



No Inactive Message Discriminator.


    Console logging: level critical, 20 messages logged, xml disabled,
                     filtering disabled
    Monitor logging: level debugging, 0 messages logged, xml disabled,
                     filtering disabled
    Buffer logging:  level debugging, 5 messages logged, xml disabled,
                     filtering disabled
    Logging Exception size (4096 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled

No active filter modules.

ESM: 0 messages dropped

    Trap logging: level informational, 37 message lines logged

Log Buffer (64000 bytes):

Nov  4 18:03:05.551: %SYS-5-CONFIG_I: Configured from console by console
Host#

让我们触发一个 ICMP 调试消息。

Host_2#ping 192.168.0.1 repeat 1

Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
.
Success rate is 0 percent (0/1)
Host_2#
Host_2#
Host_2#ping 192.168.0.1 repeat 1

Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 12/12/12 ms
Host_2#

让我们查找系统日志:

Host#show log
Syslog logging: enabled (12 messages dropped, 0 messages rate-limited,
                0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.



No Inactive Message Discriminator.


    Console logging: level critical, 20 messages logged, xml disabled,
                     filtering disabled
    Monitor logging: level debugging, 0 messages logged, xml disabled,
                     filtering disabled
    Buffer logging:  level debugging, 6 messages logged, xml disabled,
                     filtering disabled
    Logging Exception size (4096 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled

No active filter modules.

ESM: 0 messages dropped

    Trap logging: level informational, 37 message lines logged

Log Buffer (64000 bytes):

Nov  4 18:03:05.551: %SYS-5-CONFIG_I: Configured from console by console
Nov  4 18:04:47.527: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Host#

让我们发出通常会导致烦人消息的命令:

Host#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Host(config)#
Host(config)#interface fastethernet0/0
Host(config-if)#
Host(config-if)#shut
Host(config-if)#
Host(config-if)#exit
Host(config)#
Host(config)#
Host(config)#interface fastethernet0/1
Host(config-if)#
Host(config-if)#shut
Host(config-if)#    
Host(config-if)#exit
Host(config)#
Host(config)#end
Host#

让我们查找系统日志:

Host#show log
Syslog logging: enabled (12 messages dropped, 0 messages rate-limited,
                0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.



No Inactive Message Discriminator.


    Console logging: level critical, 20 messages logged, xml disabled,
                     filtering disabled
    Monitor logging: level debugging, 0 messages logged, xml disabled,
                     filtering disabled
    Buffer logging:  level debugging, 11 messages logged, xml disabled,
                     filtering disabled
    Logging Exception size (4096 bytes)
    Count and timestamp logging messages: disabled
    Persistent logging: disabled

No active filter modules.

ESM: 0 messages dropped

Trap logging: level informational, 42 message lines logged

Log Buffer (64000 bytes):

Nov  4 18:03:05.551: %SYS-5-CONFIG_I: Configured from console by console
Nov  4 18:04:47.527: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  4 18:11:57.371: %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down
Nov  4 18:11:58.371: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down
Nov  4 18:12:07.619: %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down
Nov  4 18:12:08.619: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1,     changed state to down
Nov  4 18:12:36.111: %SYS-5-CONFIG_I: Configured from console by console
Host#
  • 我喜欢什么:我可以在 CLI 上工作而不会中断。
  • 我不喜欢的:我仍然收到未记录的消息debug ip icmp。

使用cpt_fink的解决方案标记为正确答案的示例:

配置:

Router_1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router_1(config)#
Router_1(config)#logging console
Router_1(config)#
Router_1(config)#logging console critical
Router_1(config)#
Router_1(config)#logging buffered 64000 debug
Router_1(config)#
Router_1(config)#do clock set 07:29:30 5 november 2014
Router_1(config)#
Router_1(config)#end
Router_1#
Router_1#debug ip icmp
ICMP packet debugging is on
Router_1#

让我们创建至少一条消息:

Router_2#ping 192.168.0.1 repeat 2

Type escape sequence to abort.
Sending 2, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!
Success rate is 100 percent (2/2), round-trip min/avg/max = 4/4/4 ms
Router_2#

让我们查找系统日志:

Router_1#show logging | include ICMP
Nov  5 07:30:05.463: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:30:05.467: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Router_1#

让我们挑起更多消息:

Router_2#ping 192.168.0.1 repeat 11

Type escape sequence to abort.
Sending 11, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!!!!!!!
Success rate is 100 percent (11/11), round-trip min/avg/max = 4/4/4 ms
Router_2#

让我们查找系统日志:

Router_1#show logging | include ICMP
Nov  5 07:30:05.463: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:30:05.467: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.807: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.811: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.815: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.819: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.823: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.827: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.831: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.835: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.839: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.843: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Nov  5 07:32:24.847: ICMP: echo reply sent, src 192.168.0.1, dst 192.168.0.2
Router_1#
cisco
  • 1 1 个回答
  • 4991 Views

1 个回答

  • Voted
  1. Best Answer
    cpt_fink
    2014-11-05T09:22:35+08:002014-11-05T09:22:35+08:00

    我建议您使用该命令查看历史输出,logging console critical而不会用消息阻塞低速物理控制台,同时仍会在控制台上接收关键或更高级别的消息。logging buffered 64000 debugsho log

    在使用日志缓冲区时,正确设置系统时间(使用 NTP 或clock set ...来自 exec)和时区/夏令时clock timezone XXX -#以及clock summer-time XXX recurring使用 service timestamps log datetime local ms和service timestamps debug date local ms命令在输出消息时标记消息也很有用。

    作为旁注terminal monitor(并terminal no monitor禁用它)是一种在远程连接时立即获得输出的方法。您可以将 设置logging monitor [level]为包含调试或仅包含更高重要性的消息。

    • 0

相关问题

  • 为 Cisco ASA 5510 上的端口 443/80 创建 NAT 规则和安全策略

  • 识别连接到交换机的机器

  • Cisco WS-C6509-E Arp 缓存损坏问题?

  • 广播 SSID 对客户端体验有何影响?

  • DHCP/网络问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve