【发布时间】:2019-11-25 06:08:45
【问题描述】:
我想限制日志文件的大小,如果超过了大小,旧消息将被静默丢弃,就像一个环形缓冲区。
我认为output channel 不符合我的要求。
那么,我该怎么办?
有关更多信息,我为 syslogd 找到了 clog patch。
【问题讨论】:
我想限制日志文件的大小,如果超过了大小,旧消息将被静默丢弃,就像一个环形缓冲区。
我认为output channel 不符合我的要求。
那么,我该怎么办?
有关更多信息,我为 syslogd 找到了 clog patch。
【问题讨论】:
使用rotate 0 只保留一个文件
"/var/log/sample.log" {
minsize 9M
rotate 0
}
人轮换
rotate count Log files are rotated count times before being removed or mailed to the address specified in a mail directive. If count is 0, old versions are removed rather than rotated. If count is -1, old logs are not removed at all (use with caution, may waste performance and disk space). Default is 0.
【讨论】:
我的回答只针对 rsyslog。
循环日志的制作方法有很多种,见this。
例如。
local7.* /var/log/messages
然后使用 omprog 将这些方式合并到 rsyslog 中。
local7.* action(type="omprog" binary="/path/ways")
我们可以使用上述多种方式将日志记录到循环缓冲区中。
再说一句,因为循环格式是自定义的,需要相应的工具来加载内容。我想这就是为什么 rsyslog 不支持这种正式的插件。
【讨论】: