怎么搭建Linux syslog服务器抓思科交换机的日志

如题所述

将Cisco设备的日志发往syslog服务器,如下操作:

device#conf t
device(config)#logging on
device(config)#logging 172.16.86.102
device(config)#logging trap errors //日志记录级别,可用"?"查看详细内容
device(config)#logging source-interface loopback0 //日志发出用的源IP地址
device(config)#service timestamps log datetime localtime //日志记录的时间戳设置,可根据需要具体配置检验
device#sh logging

设置完成后,最好设置一下当前交换机或路由器的时钟。这样在日志服务器上就可以看到何时产生的日志。
switch#clock 9:48:00 21 Feb 2011

logging trap level //指定日志消息的级别

(0:紧急(Emergencies)
1:告警(Alerts)
2:严重的(Critical)
3:错误(Errors)
4:警告(Warnings)
5:通知(Notifications)
6:信息(Informational)
7:调试(Debugging))

syslog要考虑的主要是哪些日志需要发送到日志服务器上,即日志等级,
使用 如下命令:

device(config)#logging trap warning //日志记录级别,可用"?"查看详细内容

? emergency—Logs only emergency events.
? alert—Logs alert and more severe events.
? critical—Logs critical and more severe events.
? error—Logs error and more severe events.
? warning—Logs warning and more severe events.
? notice—Logs notice and more severe events.
? informational—Logs informational and more severe events.
? debug—Logs all events, including debug events.

为了防止日志量太大,一般设置成warning就行了。
温馨提示:答案为网友推荐,仅供参考
相似回答