Я занимаюсь разработкой программного обеспечения для платы, созданной с помощью yocto.Для системы ведения журнала я использую syslog-ng , но в настоящее время мои приложения записывают свои выходные данные в / var / log / syslog и в / var / log / mylog.Каждый из них открывает журнал таким образом:
#include <syslog.h>
int main() {
openlog("my_app_N", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL2);
...
...
...
И файл / etc / syslog-ng / syslog-ng.conf имеет это содержимое (после удаления, вероятно, ненужных закомментированных строк):
@version: 3.5
#
# Syslog-ng configuration file, compatible with default Debian syslogd
# installation. Originally written by anonymous (I can't find his name)
# Revised, and rewrited by me (SZALAY Attila <sasa@debian.org>)
# First, set some global options.
options { chain_hostnames(off); keep-timestamp(yes); flush_lines(100); use_dns(no); use_fqdn(no);
owner("root"); group("adm"); perm(0640); stats_freq(0);
bad_hostname("^gconfd$");
};
########################
# Sources
########################
# This is the default behavior of sysklogd package
# Logs may come from unix stream, but not from another machine.
#
source s_src { unix-dgram("/dev/log"); internal();
file("/proc/kmsg" program_override("kernel"));
};
########################
# Templates
########################
# Syslog-ng message template
template t_timestamp {
template("${R_DATE} ${MSGHDR}${MSG}\n");
};
########################
# Destinations
########################
# First some standard logfile
#
#--------------------------------------------------------------------------------------
#For millisecond timestamp
#Uncomment below line
options { frac_digits(3); ts_format(iso); };
destination d_syslog { file("/var/log/syslog" template(t_timestamp) create-dirs(yes)); };
destination d_error { file("/var/log/error" template(t_timestamp) create-dirs(yes)); };
destination d_crit { file("/var/log/critical" template(t_timestamp) create-dirs(yes)); };
destination d_local1 { file("/var/log/otherlog.log" template(t_timestamp) create-dirs(yes)); };
destination d_local2 { file("/var/log/mylog" template(t_timestamp) create-dirs(yes)); };
#--------------------------------------------------------------------------------------
destination d_local0 { file("/var/log/local0.log"); };
########################
# Filters
########################
# Here's come the filter options. With this rules, we can set which
# message go where.
filter f_crit { level(crit .. emerg); };
filter f_net { level(debug, info, notice, warn, alert, emerg); };
filter f_error { level(err .. emerg) ; };
filter f_local0 { facility(local0); };
filter f_local1 { facility(local1); };
filter f_local2 { program("my_app_06") or program("my_app_05") or program("my_app_04") or program("my_app_03") or program("my_app_02") or program("my_app_01") or program("my_app_00") or program("my_app_dbus_server"); };
filter f_syslog3 { not facility(auth, authpriv, mail); };
destination d_syslog_tcp { syslog("192.168.6.7" transport("tcp") port(514)); };
########################
# Log paths
########################
log { source(s_src); filter(f_error); destination(d_error); };
log { source(s_src); filter(f_crit); destination(d_crit); };
log { source(s_src); filter(f_syslog3); destination(d_syslog); destination(d_syslog_tcp); };
log { source(s_src); filter(f_local0); destination(d_local0); };
log { source(s_src); filter(f_local1); destination(d_local1); };
log { source(s_src); filter(f_local2); destination(d_local2); };
Как сделать так, чтобы my_apps записывал свои журналы только в / var / log / mylog, не записывая ничего в / var / log / syslog?