Example of a syslog walkthrough Rsyslog

Source: Internet
Author: User

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

Server Initial configuration: Other experiments are based on adding

[Email protected] ~]# vi/etc/rsyslog.conf # rsyslog v5 configuration file# for more information see/usr/share/doc/rsyslog-*/rsyslog_conf.html# If experience problems, see http://www.rsyslog.com/doc/troubleshoot.html# # # # # MODULES # # # # $ModLoad Imuxsock # provides support forLocal System logging (e.g via logger command) $ModLoad Imklog # provides kernel logging support (previously do by RKLOGD) # $ModLoad Immark # provides--mark--Message capability$modload Imuxsock # provides support forLocal System logging (e.g via logger command) $ModLoad Imklog # provides kernel logging support (previously do by RKLOGD) # $ModLoad Immark # provides--mark--message capability# provides UDP syslog reception# $ModLoad imudp$UDPServerRun 514//Remove ## provides TCP syslog reception# $ModLoad imtcp$InputTCPServerRun 10514//Remove ## # # GLOBAL directives ##### usedefaulttimestamp format$actionfiledefaulttemplate Rsyslog_traditionalfileformat
Example 1:
Server:/etc/rsyslog.conf file Last added*.* /var/log/all.log

Service Rsyslog Restart


Client:
/etc/rsyslog.conf file Last Added
*. * @@10.24.220.232:10514//via TCP


Service Rsyslog Restart
------------------------------------------------------------------------------------------
Client test program: K.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

Server View log:
Cat/var/log/all.log

June 20:44:05 slave1 log_test[12612]: PID information, pid=12612
June 20:44:05 slave1 log_test[12612]: Debug Message


 /etc/rsyslog.conf file last added  * */var /log/all.log                                                    Service rsyslog Restart client: /etc/rsyslog.conf file Last added  *. * @10.24 .   220.232 : 10514  //  through UDP  service rsyslog restart 

------------------------------------------------
Client:
[[email protected] ~]# logger "Hello World"

Server View log:
Cat/var/log/all.log

June 12 20:50:51 slave1 Root:hello World

Example 3

Server:/etc/rsyslog.conf file Last added
local5.*/var/log/all.log #过滤local5级别的日志, put/var/log/all.log


Client only joins:

local5.* @10.1.5.241:514 #通过udp传

Client testing:


Service Side display:
[Email protected] log]# Cat/var/log/all.log
June 21:06:21 slave1 Root:hello World


Example of a syslog walkthrough Rsyslog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.