Rsyslog

logrotate.conf 是否覆蓋子模組的配置?

  • April 24, 2019

我想知道哪些日誌優先於另一個。

查看此處定義的 rsyslog,它定義了每日輪換並將它們保留 30 天。

vim /etc/logrotate.d/rsyslog

/var/log/syslog
{
       rotate 30
       daily
       missingok
       notifempty
       delaycompress
       compress
       postrotate
               /usr/lib/rsyslog/rsyslog-rotate
       endscript
}

然後我們有主配置,每週輪換一次,一次保持 4 週。

vim /etc/logrotate.conf

# rotate log files weekly
weekly

# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
su root syslog

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

哪個優先於另一個?

規則在讀取時被簡單地評估,最後遇到的設置會覆蓋以前的設置。

由於/etc/logrotate.conf文件的最後一行include /etc/logrotate.d,該目錄中的文件也在主配置文件之後處理。因此,該/etc/logrotate.d/rsyslog文件將覆蓋/etc/logrotate.conf.

關鍵是您可以在主配置文件中設置預設值,並在必要時為單個日誌文件覆蓋這些預設值。

引用自:https://serverfault.com/questions/964350