系统日志和 LOCAL0..7

发布于 2024-12-18 06:33:54 字数 217 浏览 2 评论 0 原文

我们有大约 10 个不同的守护进程,我们希望为其使用 syslog 日志记录。看起来对于自​​定义应用程序,您应该使用 LOCAL0..LOCAL7 设施。那么,如果只有 8 个可能的“套接字”,那么如何区分这 10 个守护进程呢?

例如,如果我们希望每个守护进程都有一个 /var/log/daemon 文件。

We have about 10 different daemons for which we would like to use syslog logging. It looks like that for custom applications you're supposed to use LOCAL0..LOCAL7 facilities. Well, how can one then differentiate between those 10 daemons if he has only 8 possible "sockets"?

For example, if we'd like to have one /var/log/daemon<x> file per each daemon.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┊风居住的梦幻卍 2024-12-25 06:33:54

不要为此使用不同的syslog 工具。相反,将 LOG_PID 选项传递给 openlog 并适当配置您的记录器守护进程通过 syslog.conf,或者使用 rsyslog 或其他一些系统记录器(有很多)。 openlog 有一个 ident 参数,记录器守护进程可以使用它来进行区分和识别。过滤日志消息。

另一种方法是按照惯例决定日志记录应该转到 /var/log 下的某个应用程序特定文件(即仅使用 fopen fprintf,但不要忘记fflush)。这就是许多 Linux 服务器(exim4lighttpdXorg...)正在做的事情。另请参阅定义约定的 Linux 标准库

Don't use different syslog facilities for that. Instead, pass LOG_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 a ident 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> with fopen, fprintf but don't forget fflush). This is what many Linux servers (exim4, lighttpd, Xorg, ...) are doing. See also the Linux Standard Base which defines conventions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文