系统日志自定义优先级

发布于 2024-09-15 18:42:07 字数 102 浏览 12 评论 0原文

有没有一种方法可以在 syslog 守护程序或 rsyslog 守护程序中使用自定义优先级? 即我无法找到实现它的配置更改..我能做的另一件事也许是使用它的源代码。

干杯!

Is there a way one can use custom priorities in syslog daemon or rsyslog daemon?
i.e. i am unable to locate a configuration change which achives it.. the other thing i can do is perhaps play with it's source.

Cheers!

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

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

发布评论

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

评论(2

萌化 2024-09-22 18:42:07

有没有一种方法可以在 syslog 守护程序或 rsyslog 守护程序中使用自定义优先级?

系统日志输出是管理员查看的内容。系统日志由用户空间守护进程管理。

这意味着什么,如果您设法将自己的自定义优先级塞入 syslog( ) 调用,接收方,同样的用户,将无法从中获利。

为 syslog() 调用记录的优先级(或级别)非常简单,涵盖了管理员必须对错误情况关注的所有级别。因为这就是级别的用途。

我建议提出另一个问题,详细说明您真正想要实现的目标。因为发明自定义优先级是朝着错误方向迈出的一步。

PS 否则,如果它是某种跟踪或调试或诊断输出,仅在开发/测试/安装期间使用,您始终可以在日志消息中使用标准级别之一和不同的前缀。这就是我在少数情况下所做的,以便能够从系统日志(使用 grep)中仅提取特定类型的诊断信息。

Is there a way one can use custom priorities in syslog daemon or rsyslog daemon?

Syslog output is something admins look into. And the syslog is managed by the user-space daemon.

What that means, if you would manage somehow to cram your own custom priorities into the syslog() call, the receiving side, likewise the users, wouldn't be able to make much out of them.

The priorities (or levels) as they are documented for the syslog() call are pretty straightforward, covering all levels of attentions admins has to pay to the error conditions. Because that is what the levels there are for.

I would recommend posing on the SO another question with details what you really want to achieve. Because inventing custom priorities is a step in wrong direction.

P.S. Otherwise, if it is some sort of tracing or debugging or diagnostic output, used only during development/testing/installation, you can always use one of the standard levels and distinct prefix in the log message. That's what I did on few occasions to be able to extract from the syslog (with grep) only the particular types of diagnostics.

楠木可依 2024-09-22 18:42:07

调用 syslog(3) 的进程与 syslogd 守护进程之间的常用接口仅允许使用 int 优先级。这并没有为特定于应用程序的优先级留下太多空间。应用程序应使用LOG_USER 设施。应用程序可以使用 8 个设施 LOG_LOCAL0LOG_LOCAL7(经 POSIX 认可)。这些设施的分配传统上由系统管理员决定,因此您应该将设施设置为默认的配置设置LOG_USER(这也将允许管理员选择非标准设施)。

除了设施和优先级之外,一些 syslog 守护进程和大多数日志排序程序还允许按应用程序名称(openlog 的第一个参数)进行排序。这个主题最好在 Unix Stack Exchange 站点 上讨论。

The usual interface between the process that calls syslog(3) and the syslogd daemon only allows an int for the priority. This doesn't leave much room for application-specific priorities. Applications are expected to use the LOG_USER facility. There are 8 facilities LOG_LOCAL0 through LOG_LOCAL7 (sanctioned by POSIX) that can be used by applications. The allocation of these facilities is traditionally up to the system administrator, so you should make the facility a configuration setting with a default of LOG_USER (this will also allow the administrator to select a nonstandard facility).

Some syslog daemons, and most log sorting programs, allow sorting by application name (the first argument to openlog) in addition to facility and priority. This subject would be best discussed at the Unix Stack Exchange site.

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