syslog瀹炰緥璇﹁Вrsyslog

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了syslog瀹炰緥璇﹁Вrsyslog相关的知识,希望对你有一定的参考价值。

鏍囩锛?/p>

http://www.xiaomastack.com/2014/11/06/logger-rsyslog/
http://www.cnblogs.com/tobeseeker/archive/2013/03/10/2953250.html
http://www.open-open.com/lib/view/open1440982522565.html
https://linux.cn/article-4835-1.html#3_4334

鏈嶅姟鍣ㄥ垵濮嬮厤鍒讹細鍏朵粬瀹為獙鍩轰簬娣诲姞

[[email protected] ~]# vi /etc/rsyslog.conf # rsyslog v5 configuration file # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html #### MODULES #### $ModLoad imuxsock # provides support for local system logging (e.g. via logger command) $ModLoad imklog # provides kernel logging support (previously done by rklogd) #$ModLoad immark # provides --MARK-- message capability $ModLoad imuxsock # provides support for local system logging (e.g. via logger command) $ModLoad imklog # provides kernel logging support (previously done by rklogd) #$ModLoad immark # provides --MARK-- message capability # Provides UDP syslog reception #$ModLoad imudp $UDPServerRun 514 //鍘绘帀# # Provides TCP syslog reception #$ModLoad imtcp $InputTCPServerRun 10514 //鍘绘帀# #### GLOBAL DIRECTIVES #### # Use default timestamp format $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
瀹炰緥1锛?br />
鏈嶅姟鍣?
/etc/rsyslog.conf鏂囦欢鏈€鍚庢坊鍔?
*.*                                    /var/log/all.log

service rsyslog restart


瀹㈡埛绔細
/etc/rsyslog.conf鏂囦欢鏈€鍚庢坊鍔?br />*.*                                                    @@10.24.220.232:10514   //閫氳繃tcp浼?br />

service rsyslog restart
------------------------------------------------------------------------------------------
瀹㈡埛绔祴璇曡瘯绋嬪簭锛歬.c
#include <syslog.h>
int main(void){
 int log_test;
 openlog("log_test", LOG_PID|LOG_CONS, LOG_USER);
 syslog(LOG_INFO, "PID information, pid=%d\n", getpid());
 syslog(LOG_ALERT, "debug message\n");
 closelog();
 return 0;
}
[email protected] ~]# ./k 

鏈嶅姟鍣ㄦ煡鐪媗og:
cat /var/log/all.log

Jun 12 20:44:05 slave1 log_test[12612]: PID information, pid=12612
Jun 12 20:44:05 slave1 log_test[12612]: debug message


 

瀹炰緥2锛?

鏈嶅姟鍣?
/etc/rsyslog.conf鏂囦欢鏈€鍚庢坊鍔?
*.*                                    /var/log/all.log

service rsyslog restart


瀹㈡埛绔細
/etc/rsyslog.conf鏂囦欢鏈€鍚庢坊鍔?
*.*                                                    @10.24.220.232:10514   //閫氳繃udp


service rsyslog restart

------------------------------------------------
瀹㈡埛绔細
[[email protected] ~]# logger "hello world"

鏈嶅姟鍣ㄦ煡鐪媗og:
cat /var/log/all.log

Jun 12 20:50:51 slave1 root: hello world

瀹炰緥3

鏈嶅姟鍣細
/etc/rsyslog.conf鏂囦欢鏈€鍚庢坊鍔?br />local5.*        /var/log/all.log            #杩囨护local5绾у埆鐨勬棩蹇楋紝鏀惧叆/var/log/all.log


瀹㈡埛绔彧鍔犲叆锛?br />
local5.*                    @10.1.5.241:514                     #閫氳繃udp浼?br />
瀹㈡埛绔祴璇曪細
[[email protected] ~]# logger -p local5.info  "hello world"

鏈嶅姟绔樉绀猴細
[email protected] log]# cat /var/log/all.log
Jun 12 21:06:21 slave1 root: hello world


 

以上是关于syslog瀹炰緥璇﹁Вrsyslog的主要内容,如果未能解决你的问题,请参考以下文章

Echarts涓お闃冲浘锛圫unburst锛夌殑瀹炰緥

浣跨敤GFS闆嗙兢閮ㄧ讲KVM铏氭嫙鍖栧钩鍙?瀹炰緥!!!)

Spring 瀹炰緥鍖栨柟寮忔湁鍑犵锛熶负浠€涔堜細鐢ㄥ埌 Cglib锛?

榛戣嫻鏋滃紑鑽掕纭欢绡? 鏂板搧 10700K+鍦f棗 Z490 閰嶇疆瀹炰緥

linux下syslog和rsyslog

syslog-ng VS. rsyslog