标签: c logging syslog rsyslog systemd
由于syslog错误日志记录在某些Linux发行版(例如arch Linux)中过期,我正在寻找一些方法来记录systemd的错误,但我找不到任何关于它的文档或资源。如果你知道有关systemd的错误记录,请帮助我。
答案 0 :(得分:1)
如果您需要从应用程序中记录某些内容,只需按以下方式打印到stderr:
#include <systemd/sd-daemon.h>
// some code here
fprintf(stderr, SD_ERR "Some error meassge from the app");
// some code there
如果要在命令提示符下输入消息:
$ systemd-journalctl
请参阅this和that以及that。