如何在没有`/ etc / logrotate.d / rsyslog`的情况下配置logrotate?

我正在尝试在我的Ubuntu计算机上配置日志轮换,以便每天轮换日志并保留14天。 我发现的大多数教程,例如这个 ,都提到我应该修改/etc/logrotate.d/rsyslog但我的机器上不存在该文件。 如何判断存储日志转换设置的位置? 在Ubuntu 16.04中需要修改哪个文件来配置每日日志轮换?

当我看到man logrotate ,看起来配置在/etc/logrotate.conf 。 这是该文件的内容:

 # see "man logrotate" for details # 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 # no packages own wtmp, or btmp -- we'll rotate them here /var/log/wtmp { missingok monthly create 0664 root utmp rotate 1 } /var/log/btmp { missingok monthly create 0660 root utmp rotate 1 } # system-specific logs may be configured here 

这就是那里的一切。 我尝试将weekly更改为dailyrotate 4rotate 10但现在/var/log/syslog没有出现任何日志

我错过了什么? 我是否需要将/var/log/syslog的设置添加到此文件中?

您不需要/etc/logrotate.d/rsyslog文件来轮换日志。 您在/etc/logrotate.d目录中创建的任何文件都可用于轮换日志。 这些文件通常使用root所有权和644权限(rx-r – r–)创建。

我的14.04服务器上有/etc/logrotate.d/rsyslog文件,这些是内容。

 /var/log/syslog { rotate 7 daily missingok notifempty delaycompress compress postrotate reload rsyslog >/dev/null 2>&1 || true endscript } /var/log/mail.info /var/log/mail.warn /var/log/mail.err /var/log/mail.log /var/log/daemon.log /var/log/kern.log /var/log/auth.log /var/log/user.log /var/log/lpr.log /var/log/cron.log /var/log/debug /var/log/messages { rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate reload rsyslog >/dev/null 2>&1 || true endscript } 

如果syslog文件是在使用错误的权限和所有权轮换后创建的,则syslog文件中可能没有日志。 我的设置为640权限(rw-r —–)和syslog:adm作为所有者和组。