Linux - Syslog 客户端

发布于 2024-12-10 09:26:39 字数 909 浏览 0 评论 0原文

为了开发跨平台的系统日志客户端,我尝试在不使用系统日志系统调用的情况下完成它。我正在用 C++ 开发这个客户端,现在在 Linux 中进行测试。我要替换的旧系统日志客户端与系统日志系统调用完美配合。 至于如何,根本行不通。跟踪信息不在 /var/log/user.log 中,它应该在其他任何地方(greped)。但当我使用 netcat 监听正确的端口时,我确实收到了它。顺便说一句,端口 514 不应该已经在使用中吗?

跟踪应该在 UDP/514 上发送。我尝试坚持 RFC 3164,但仍然明显有问题。

如果有人能给我提示来解决这个问题,我真的很感激。

Trace: severity: 2 (Critical); facility: 23 (Local Use 7) ==> priority: 186

sh$> sudo nc -ul localhost -p 514
  <186>Oct 18 10:36:03 hostname test_trace: | 10:36:03.242995 | CRIT  | xxx-MAIN[5473-000] | 00000 | 0008 : main : user_msg

谢谢 !


我想我在自己的问题中发现了问题:Rsyslog(我的系统日志服务器)无法正确侦听 UDP/514。

/etc/rsyslog.conf

$ModLoad imudp
$UDPServerAddress 0.0.0.0
$UDPServerRun 514

如果有人知道为什么它仍然不监听 UDP/514,我会非常感激,因为我真的不明白为什么。

再次感谢您。

In order to develop a cross-plateform syslog client, I am trying to do it without using the syslog syscall. I am developping this client in C++ and for now testing in Linux. The old syslog client that I am replacing was working perfectly fine with the syslog syscall.
For how, it simply doesn't work. The trace is not in /var/log/user.log like it should be, either anywhere else (greped). But I do receive it when I listen on the right port with netcat. Shouldn't the port 514 be already in use by the way ?

The trace is as it should be sent on UDP/514. I tried to stick the RFC 3164 but something is still obviously wrong.

Id really appreciate if someone could give me a hint to solve this.

Trace: severity: 2 (Critical); facility: 23 (Local Use 7) ==> priority: 186

sh
gt; sudo nc -ul localhost -p 514
  <186>Oct 18 10:36:03 hostname test_trace: | 10:36:03.242995 | CRIT  | xxx-MAIN[5473-000] | 00000 | 0008 : main : user_msg

Thank you !


I think I found the problem in my own question: Rsyslog (my syslog server) doesn't listen on UDP/514 correctly.

/etc/rsyslog.conf

$ModLoad imudp
$UDPServerAddress 0.0.0.0
$UDPServerRun 514

If someone has any idea of why it still doesn't listen on UDP/514, I'd be really thanksful cause I really don't see why.

Thank you again.

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

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

发布评论

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

评论(1

翻身的咸鱼 2024-12-17 09:26:39

syslog() 调用写入 /dev/log,系统记录器读取此 unix 域套接字以获取消息。 UDP/514用于网络传输。
所以不清楚你想要什么。

The syslog() call writes to /dev/log and the system logger reads this unix domain socket to pick up the message. UDP/514 is for network transmission.
So it is not clear what you want.

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