系统日志和 LOCAL0..7
我们有大约 10 个不同的守护进程,我们希望为其使用 syslog 日志记录。看起来对于自定义应用程序,您应该使用 LOCAL0
..LOCAL7
设施。那么,如果只有 8 个可能的“套接字”,那么如何区分这 10 个守护进程呢?
例如,如果我们希望每个守护进程都有一个 /var/log/daemon
文件。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要为此使用不同的
syslog
工具。相反,将LOG_PID
选项传递给 openlog 并适当配置您的记录器守护进程通过 syslog.conf,或者使用 rsyslog 或其他一些系统记录器(有很多)。openlog
有一个ident
参数,记录器守护进程可以使用它来进行区分和识别。过滤日志消息。另一种方法是按照惯例决定日志记录应该转到
/var/log
下的某个应用程序特定文件(即仅使用
和fopen
、fprintf
,但不要忘记fflush
)。这就是许多 Linux 服务器(exim4
、lighttpd
、Xorg
...)正在做的事情。另请参阅定义约定的 Linux 标准库。Don't use different
syslog
facilities for that. Instead, passLOG_PID
option to openlog and configure appropriately your logger daemon thru syslog.conf, or perhaps use rsyslog or some other syslogger (there are many of them).openlog
has aident
argument which can be used by logger dameons for discrimination & filtering of log messages.And alternative would be to conventionally decide that logging should go to some application specific file under
/var/log
(i.e. use just<stdio.h>
withfopen
,fprintf
but don't forgetfflush
). This is what many Linux servers (exim4
,lighttpd
,Xorg
, ...) are doing. See also the Linux Standard Base which defines conventions.