logrotate.conf 是否覆盖子模块的配置?

Hou*_*man 3 logrotate rsyslog ubuntu-18.04

我想知道哪个日志优先于另一个。

查看此处定义的 rsyslog,它定义了每日轮换并将它们保留 30 天。

vim /etc/logrotate.d/rsyslog

/var/log/syslog
{
        rotate 30
        daily
        missingok
        notifempty
        delaycompress
        compress
        postrotate
                /usr/lib/rsyslog/rsyslog-rotate
        endscript
}
Run Code Online (Sandbox Code Playgroud)

然后我们有主要配置,每周轮换一次,一次保持 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
Run Code Online (Sandbox Code Playgroud)

哪个优先于另一个?

wur*_*tel 6

规则只是在读取时进行评估,最后遇到的设置会覆盖以前的设置。

由于/etc/logrotate.conf文件include /etc/logrotate.d最后一行,该目录中的文件也在主配置文件之后处理。因此,该/etc/logrotate.d/rsyslog文件将覆盖/etc/logrotate.conf.

关键是您可以在主配置文件中设置默认值,并在必要时覆盖单个日志文件的默认值。