Python Syslog添加标签和设施

发布于 2025-02-04 04:06:50 字数 449 浏览 3 评论 0原文

我正在使用python syslog 库。我想在日志中添加标签功能。但是,似乎没有一种添加标签的方法。

有一个功能参数,但是我需要一个自定义字符串。

有没有办法实现以下内容:

import syslog
syslog.openlog(logoption=syslog.LOG_PID, facility="myapp", tag="mytag")
syslog.syslog('myapp processing initiated...')

I am using the python syslog library. I want to add a tag and facility to the log. But there doesn't seem to be a way to add a tag.

There is a facility argument, but I need a custom string.

Is there a way to achieve something like the following:

import syslog
syslog.openlog(logoption=syslog.LOG_PID, facility="myapp", tag="mytag")
syslog.syslog('myapp processing initiated...')

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

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

发布评论

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

评论(1

不念旧人 2025-02-11 04:06:50

python syslog库没有标签参数。

syslog.openlog([[IDESS [,logoption [,Facity]]])

相反,您可以使用distions参数。

syslog.openlog("mytag", logoption=syslog.LOG_PID, facility=syslog.LOG_LOCAL0)

功能而不是“ myApp”之类的字符串。这是应将日志写入的文件。

设施:

log_kern,log_user,log_mail,log_daemon,log_auth,log_lpr,log_news,log_uucp,log_cron,log_syslog,log_local0 to log_local7 to log_local7,以及在&logt; syslog.h> syslog.h>,syslog.h> ,,> ,,

The python syslog library doesn't have a tag argument.

syslog.openlog([ident[, logoption[, facility]]])

Instead you can use the ident argument.

syslog.openlog("mytag", logoption=syslog.LOG_PID, facility=syslog.LOG_LOCAL0)

The facility instead cannot be a string like "myapp". It's the file where the logs should be written to.

Facilities:

LOG_KERN, LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH, LOG_LPR, LOG_NEWS, LOG_UUCP, LOG_CRON, LOG_SYSLOG, LOG_LOCAL0 to LOG_LOCAL7, and, if defined in <syslog.h>, LOG_AUTHPRIV.

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