1.options选项的配置
options {
chain_hostnames(0);
time_reopen(10);
time_reap(360);
log_fifo_size(2048);
create_dirs(yes);
group(adm);
perm(0644);
dir_perm(0755);
use_dns(no);
stats_freq(0);
bad_hostname("^gconfd$");
};
2.消息源的配置,如下:
source sall {
# message generated by Syslog-NG
internal();
# standard Linux log source (this is the default place for the syslog()
# function to send logs to)
unix-stream("/dev/log");
# messages from the kernel
file("/proc/kmsg" logprefix("kernel: ")); # use the following line if you want to receive remote UDP logging messages
# (this is equivalent to the "-r" syslogd flag)
# udp();
}
3.destinations的配置,如下:
destination dfauth { file("/var/log/auth.log"); };
destination dfsyslog { file("/var/log/syslog"); };
destination dfcron { file("/var/log/cron.log"); };
destination dfdaemon { file("/var/log/daemon.log"); };
destination dfkern { file("/var/log/kern.log"); };
destination dflpr { file("/var/log/lpr.log"); };
destination dfmail { file("/var/log/mail.log"); };
destination dfuser { file("/var/log/user.log"); };
destination dfuucp { file("/var/log/uucp.log"); };
destination df167 { tcp("127.0.0.1" port(2345)); };
4.filters的配置,如下:
filter fcron { facility(cron); };
filter fdaemon { facility(daemon); };
filter fkern { facility(kern); };
filter flpr { facility(lpr); };
filter fmail { facility(mail); };
filter fnews { facility(news); };
filter fuser { facility(user); };
filter fuucp { facility(uucp); };
5.模板的配置,如下:
template linyanwenfmt{template("$DATE $PRIORITY $MSG\n");templateescape(no);};
6.进程的匹配,如下:
filter f_linyanwen{program("_5$");};
7.日志输出位置的配置,如下:
destination dlinyanwen{file("data/yy/log/$PROGRAM/$PROGRAM.log" template(linyanwenfmt));};
8.完整的log指令,如下:
log{source(sall);filter(flinyanwen);destination(d_linyanwen);flags(final);};
9.运行结果,如下:
10.停止syslog-ng:/etc/init.d/service syslog-ng stop
转载请注明出处:山水间博客
http://blog.csdn.net/linyanwen99/article/details/8456054