gpt4 book ai didi

c - 需要systemd错误日志文件

转载 作者:行者123 更新时间:2023-11-30 15:44:10 25 4
gpt4 key购买 nike

由于 syslog 错误日志记录在某些 Linux 发行版(例如 arch Linux)中已过期,我正在寻找某种方法来使用 systemd 记录错误,但我找不到任何有关它的文档或资源。如果您了解 systemd 的错误日志记录,请帮助我。

最佳答案

如果您需要从应用程序记录某些内容,只需以如下方式打印到 stderr:

#include <systemd/sd-daemon.h>

// some code here

fprintf(stderr, SD_ERR "Some error meassge from the app");

// some code there

如果您想在命令提示符处输入消息:

$ systemd-journalctl

参见thisthatthat .

关于c - 需要systemd错误日志文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19609592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com