ubuntu守护进程rsyslog.conf_栈_百度空间

ubuntu守护进程rsyslog.conf_栈_百度空间

ubuntu守护进程rsyslog.conf
2010年04月18日 星期日 11:11
今天在学习守护进程时,看到一个实验,却无法得到结果。发现可能是Linux版本不同,结果配置文件也不同


首先,ubuntu的配置文件为/etc/rsyslog.conf,不再是/etc/syslog.conf。


其次,编辑/etc/rsyslog.conf,在其中添加配置文件

local2.debug         /var/log/cisco.log

local2.info              /var/log/test.log

然后重新启动一下syslog服务,sudo /etc/init.d/rsyslog restart,就回看见var/log中多出了cisco.log和test.log两个文件


最后    编译运行下列代码:

#include<syslog.h>

#include<unistd.h>

int main()

{

openlog("here",LOG_PID,LOG_USER);

syslog(LOG_INFO|LOG_LOCAL2,"OK");

closelog();

}


再查看/var/log/test.log的内容,就会发现有下列内容:

Apr 18 11:02:05 ubuntu here[3574]: OK
原文地址:https://www.cnblogs.com/lexus/p/2467866.html