{"id":4762,"date":"2019-08-24T23:41:22","date_gmt":"2019-08-24T15:41:22","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=4762"},"modified":"2019-08-24T23:41:28","modified_gmt":"2019-08-24T15:41:28","slug":"syslog","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/syslog","title":{"rendered":"syslog\u547d\u4ee4 – \u7cfb\u7edf\u9ed8\u8ba4\u7684\u65e5\u5fd7\u5b88\u62a4\u8fdb\u7a0b"},"content":{"rendered":"\n

syslog \u662fLinux\u7cfb\u7edf\u9ed8\u8ba4\u7684\u65e5\u5fd7\u5b88\u62a4\u8fdb\u7a0b\u3002\u9ed8\u8ba4\u7684syslog\u914d\u7f6e\u6587\u4ef6\u662f\/etc\/syslog.conf\u6587\u4ef6\u3002\u7a0b\u5e8f\uff0c\u5b88\u62a4\u8fdb\u7a0b\u548c\u5185\u6838\u63d0\u4f9b\u4e86\u8bbf\u95ee\u7cfb\u7edf\u7684\u65e5\u5fd7\u4fe1\u606f\u3002\u56e0\u6b64\uff0c\u4efb\u4f55\u5e0c\u671b\u751f\u6210\u65e5\u5fd7\u4fe1\u606f\u7684\u7a0b\u5e8f\u90fd\u53ef\u4ee5\u5411 syslog \u63a5\u53e3\u547c\u53eb\u751f\u6210\u8be5\u4fe1\u606f\u3002<\/p>\n\n\n\n

\u51e0\u4e4e\u6240\u6709\u7684\u7f51\u7edc\u8bbe\u5907\u90fd\u53ef\u4ee5\u901a\u8fc7syslog\u534f\u8bae\uff0c\u5c06\u65e5\u5fd7\u4fe1\u606f\u4ee5\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae(UDP)\u65b9\u5f0f\u4f20\u9001\u5230\u8fdc\u7aef\u670d\u52a1\u5668\uff0c\u8fdc\u7aef\u63a5\u6536\u65e5\u5fd7\u670d\u52a1\u5668\u5fc5\u987b\u901a\u8fc7syslogd\u76d1\u542cUDP \u7aef\u53e3514\uff0c\u5e76\u6839\u636e syslog.conf\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u5904\u7406\u672c\u673a\uff0c\u63a5\u6536\u8bbf\u95ee\u7cfb\u7edf\u7684\u65e5\u5fd7\u4fe1\u606f\uff0c\u628a\u6307\u5b9a\u7684\u4e8b\u4ef6\u5199\u5165\u7279\u5b9a\u6587\u4ef6\u4e2d\uff0c\u4f9b\u540e\u53f0\u6570\u636e\u5e93\u7ba1\u7406\u548c\u54cd\u5e94\u4e4b\u7528\u3002\u610f\u5473\u7740\u53ef\u4ee5\u8ba9\u4efb\u4f55\u4e8b\u4ef6\u90fd\u767b\u5f55\u5230\u4e00\u53f0\u6216\u591a\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u4ee5\u5907\u540e\u53f0\u6570\u636e\u5e93\u7528off-line(\u79bb\u7ebf) \u65b9\u6cd5\u5206\u6790\u8fdc\u7aef\u8bbe\u5907\u7684\u4e8b\u4ef6\u3002<\/p>\n\n\n\n

\u901a\u5e38\uff0csyslog \u63a5\u53d7\u6765\u81ea\u7cfb\u7edf\u7684\u5404\u79cd\u529f\u80fd\u7684\u4fe1\u606f\uff0c\u6bcf\u4e2a\u4fe1\u606f\u90fd\u5305\u62ec\u91cd\u8981\u7ea7\u3002\/etc\/syslog.conf \u6587\u4ef6\u901a\u77e5 syslogd \u5982\u4f55\u6839\u636e\u8bbe\u5907\u548c\u4fe1\u606f\u91cd\u8981\u7ea7\u522b\u6765\u62a5\u544a\u4fe1\u606f\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong> show syslog [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n
statistics<\/td>\u7edf\u8ba1\u4fe1\u606f<\/td><\/tr>
error<\/td>\u5f02\u5e38\u65e5\u5fd7<\/td><\/tr>
memory<\/td>\u5185\u5b58\u65e5\u5fd7<\/td><\/tr><\/tbody><\/table>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u8981\u5411syslog\u6587\u4ef6\/var\/log\/messages\u4e2d\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# logger this is a test log line <\/pre>\n\n\n\n

\u663e\u793a\u7cfb\u7edf\u6240\u6709\u5185\u6838\u65e5\u5fd7\u7edf\u8ba1\u8868\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# show syslog statistics<\/pre>\n\n\n\n

\u663e\u793a\u7cfb\u7edf\u6240\u6709\u5f02\u5e38\u65e5\u5fd7\u4fe1\u606f:<\/p>\n\n\n\n

[root@linuxcool ~]# show system log error<\/pre>\n\n\n\n

\u663e\u793a\u65e5\u5fd7\u914d\u7f6e\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# show log-config<\/pre>\n\n\n\n

\u663e\u793a\u5185\u5b58\u65e5\u5fd7\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# show log memory notice<\/pre>\n","protected":false},"excerpt":{"rendered":"

syslog \u662fLinux\u7cfb\u7edf\u9ed8\u8ba4\u7684\u65e5\u5fd7\u5b88\u62a4\u8fdb\u7a0b\u3002\u9ed8\u8ba4\u7684syslog\u914d\u7f6e\u6587\u4ef6\u662f\/etc\/syslog […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4762"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=4762"}],"version-history":[{"count":4,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4762\/revisions"}],"predecessor-version":[{"id":4799,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4762\/revisions\/4799"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=4762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=4762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=4762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}