【问题标题】:Metalog all logs are printed with [kernel]Metalog 所有日志都用 [kernel] 打印
【发布时间】:2018-12-05 10:35:31
【问题描述】:

我安装了 metalog 我的服务器并使用 C++ 应用程序来编写日志。 这是我打印到系统日志的方式

openlog(facility.c_str(), LOG_CONS | LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_LOCAL0);

syslog(LOG_INFO, "%s", stderr_msg.c_str());

我所有的日志都以以下格式打印:

<date> [kernel] <log text message>

例如

Dec 05 12:19:31 [kernel] this is an example of log

我想改变它而不是[内核],它会打印相关模块。 或者至少是我的应用程序名称,但不是“内核”。 我该怎么做?

【问题讨论】:

    标签: c++ linux-kernel syslog


    【解决方案1】:

    我的问题是我从另一个进程启动 Metalog,它将其 stdout 和 stderr 指向 /dev/kmsg,因此 Metalog 的分叉进程也是如此。这导致日志看起来像是来自内核。

    【讨论】:

      猜你喜欢
      • 2017-03-27
      • 1970-01-01
      • 2012-05-16
      • 2014-04-08
      • 2018-01-16
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多