用于生成系统日志消息的 C 语言标准接口
哪种方式是用 C 语言生成 IETF-syslog 消息的标准方法?
有标题
当然,可以手动将消息直接构造到套接字。但似乎这样的方式并不标准。
还有其他标准方法吗?
Which way is standard to generate IETF-syslog messages in the C language?
There is the header <syslog.h>. But it provide no options to use the STRUCTURED-DATA mechanism (rfc-5424).
Of course, messages could be constructed by hand directly to a socket. But it seems that such way is not standard.
Is there another standard way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
执行此操作的标准方法是让应用程序使用正常的
openlog()
、syslog()
和closelog()
例程来记录消息
。这会将消息发送到本地计算机上运行的 syslogd。如果随后要使用 syslog 协议通过网络转发消息,
syslogd
本身将处理此问题。例如,这可以使用syslogd.conf
文件中的@hostname
之类的目标来完成。简而言之,您的应用程序应将消息记录到 syslogd,然后 syslogd 决定将消息发送到何处(包括通过网络)。这允许本地管理员最大限度地控制。
The standard way to do this is to have your application log messages using the normal
openlog()
,syslog()
andcloselog()
routines from<syslog.h>
.That will send the messages to the
syslogd
running on the local machine. If the messages are then to be forwarded over the network using the syslog protocol,syslogd
itself will take care of this. For example, this might be done using a target like@hostname
in thesyslogd.conf
file.In short, your application is expected to log messages to the
syslogd
, andsyslogd
decides where to send them (including over the network). This allows the local administrator maximum control.嗯... 该 RFC 的历史还不到 2 年。我认为看到常见的嫌疑人尚未实施它并不令人感到惊讶。
Hmmm... that RFC is less than 2 years old. I don't think it is a big surprise to see that the ususal suspects haven't implemented it yet.