【问题标题】:where syslog store error messagessyslog 存储错误消息的位置
【发布时间】:2012-08-18 06:13:37
【问题描述】:

syslog() 生成日志消息

syslog(LOG_ERR, "%s failed: %d (%m)", str, errno);系统日志(LOG_NOTICE, "%s 失败: %d (%m)", str, errno);系统日志(LOG_INFO,"%s",str);

它在哪里存储这些信息?

我在服务器中找不到任何名为 LOG_ERR、LOG_NOTICE、LOG_INFO 的文件。

请提出建议。

【问题讨论】:

  • 你的 Linux 是什么? Ubuntu? Debian?...

标签: c linux syslog


【解决方案1】:

在 Linux 下你可以在这里找到它们:/var/log/syslog,如果你运行这个简单的程序:

#include <syslog.h>

int main(int argc, char **argv)
{
        /* Various syslog messages */
        syslog (LOG_CRIT, "%s", "That's critic");
        syslog(LOG_ALERT, "An alert\n");
        syslog(LOG_ERR, "Error on this DAEMON\n");

        return 0;
}

然后打开终端并运行:

toc@UnixServer:/var/log$ tail -f syslog

你应该看到这样的东西:

Aug 18 08:42:21 TarekServer SYSLOG: That's critic
Aug 18 08:42:21 TarekServer SYSLOG: An alert
Aug 18 08:42:21 TarekServer SYSLOG: Error on this DAEMON

【讨论】:

    【解决方案2】:

    它们被转储到 syslog 缓冲区中,syslogd/rsyslogd 将它们拾取并将它们放置在由其在 /etc 中的配置确定的适当位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多