I use the following code below (source) to keep the log files:
我使用下面的代码(源代码)来保存日志文件:
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
int main(void) {
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);
syslog(LOG_INFO, "A different kind of Hello world ... ");
closelog();
return 0;
}
I run the program on ubuntu and it keeps the logs on /var/log/syslog
, how can I set the logs to be kept on e.g. /var/log/mylog
?
我在ubuntu上运行该程序并将日志保存在/ var / log / syslog上,如何设置日志保持在例如在/ var /日志/ mylog?
1 个解决方案
#1
1
During openlog, use a special facility, so that you can modify your syslog.conf file to direct such logs to any log file you specified.
在openlog期间,使用特殊工具,以便您可以修改syslog.conf文件以将此类日志定向到您指定的任何日志文件。
Don't forget to remove such facility from the default syslog - by default all logs goes to syslog.
不要忘记从默认的syslog中删除这样的工具 - 默认情况下,所有日志都会转到syslog。
#1
1
During openlog, use a special facility, so that you can modify your syslog.conf file to direct such logs to any log file you specified.
在openlog期间,使用特殊工具,以便您可以修改syslog.conf文件以将此类日志定向到您指定的任何日志文件。
Don't forget to remove such facility from the default syslog - by default all logs goes to syslog.
不要忘记从默认的syslog中删除这样的工具 - 默认情况下,所有日志都会转到syslog。