简体   繁体   English

访问C中的时间戳-系统日志

[英]Access to timestamp in C - syslog ng

I'm working on a C project, with client/server syslog communication with a Rpi. 我正在一个C项目中,与Rpi进行客户端/服务器syslog通信。 I have been asked to use syslog ng and I'd like to access to timestamp. 我被要求使用syslog ng,我想访问时间戳。

From what I found here : 从我在这里找到的:

Where the timestamp comes from depends on the type of log data you're sending through. 时间戳记的来源取决于您通过其发送的日志数据的类型。

Plus : 加号:

If your data is forwarded by a syslog service, there is a timestamp embedded in the header that we can pull out and use. 如果您的数据是通过syslog服务转发的,则标头中嵌入了一个时间戳,我们可以提取并使用该时间戳。

So it's possible to pull out the timestamp. 因此可以拉出时间戳记。 But how ? 但是如何?

If you use syslog-ng, it handles two different time stamps: 如果使用syslog-ng,它将处理两个不同的时间戳:

  • the one, when the message was actually received 一个,实际收到消息的时间
  • the one included in the syslog message syslog消息中包含的一个

These are accessible through macros. 这些可以通过宏访问。 You can read more about it at https://www.balabit.com/sites/default/files/documents/syslog-ng-ose-3.7-guides/en/syslog-ng-ose-v3.7-guide-admin/html-single/index.html#reference-macros 您可以在https://www.balabit.com/sites/default/files/documents/syslog-ng-ose-3.7-guides/zh-CN/syslog-ng-ose-v3.7-guide-admin中了解更多信息/html-single/index.html#reference-macros

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM