【问题标题】:Syslog and daily files in CC 中的 Syslog 和日常文件
【发布时间】:2021-05-09 15:33:47
【问题描述】:

我配置了/etc/syslog.conf:

local0.debug /custom/path/log/app.log

以便系统日志记录到自定义日志文件。

openlog("app", LOG_PID, LOG_LOCAL0);

现在我还希望 syslog 每天创建一个不同的文件,例如:

/custom/path/log/20210204_app.log

/custom/path/log/20210205_app.log

我该怎么做?

【问题讨论】:

    标签: c linux logging syslog


    【解决方案1】:

    使用 logrotate 并使用您的文件和策略配置 /etc/logrotate.d/apt。 像这样的东西可以完成这项工作。

    /custom/path/log/app.log {
      rotate 12
      daily
      missingok
      notifempty
    }
    

    更多信息请看这里https://www.digitalocean.com/community/tutorials/how-to-manage-logfiles-with-logrotate-on-ubuntu-16-04

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      相关资源
      最近更新 更多