首页 > 解决方案 > freebsd newsyslog.conf.d 设置归档目录

问题描述

在 FreeBSD 上,我有一个名为

我的网站

/usr/local/etc/newsyslog.conf.d

文件的内容my_site是这样的:

/path/to/site/log/site.access_log 644 7 1048576 * GCZ /var/run/nginx.pid  30

现在我需要知道如何指定归档目标目录。

我在文档中没有找到如何在配置文件中设置存档目录的任何内容。

标签: freebsdlogrotate

解决方案


检查NEWSYSLOG(8)底部的部分Files

FILES
     /etc/newsyslog.conf              newsyslog configuration file
     /etc/newsyslog.conf.d            Each file in this directory will be
                                      included by the default newsyslog.conf.
     /usr/local/etc/newsyslog.conf.d  Each file in this directory will be
                                      included by the default newsyslog.conf.

例如,如果您想旋转,您可以使用以下内容/var/log/daemon.log创建文件:/etc/newsyslog.conf.d/extra.conf

/var/log/daemon.log                        600  7     *    @T00  J

然后测试(不要旋转)运行这个:

# newsyslog -nv

-n将导致newsyslog不修剪日志,而是打印出如果未指定此选项将执行的操作。

-v用于详细模式。

所以你可能会看到这样的东西:

Processing /etc/newsyslog.conf
Found: <include> /etc/newsyslog.conf.d/*
Found: <include> /usr/local/etc/newsyslog.conf.d/*
Processing /etc/newsyslog.conf.d/extra.conf
var/log/all.log <7J>: --> will trim at Wed Apr 25 00:00:00 2018
/var/log/amd.log <7J>: does not exist, skipped.
/var/log/auth.log <7J>: --> will trim at Tue Jan  1 00:00:00 2019
/var/log/console.log <5J>: does not exist, skipped.
/var/log/cron <3J>: size (Kb): 1 [100] --> skipping
/var/log/daily.log <7J>: does not exist, skipped.
/var/log/debug.log <7J>: size (Kb): 1 [100] --> skipping
/var/log/init.log <3J>: does not exist, skipped.
/var/log/kerberos.log <7J>: does not exist, skipped.
/var/log/lpd-errs <7J>: size (Kb): 1 [100] --> skipping
/var/log/maillog <7J>: --> will trim at Wed Apr 25 00:00:00 2018
/var/log/messages <5J>: --> will trim at Tue Jan  1 00:00:00 2019
/var/log/monthly.log <12J>: does not exist, skipped.
/var/log/pflog <3J>: size (Kb): 60 [100] --> skipping
/var/log/ppp.log <3J>: size (Kb): 1 [100] --> skipping
/var/log/devd.log <3J>: size (Kb): 1 [100] --> skipping
/var/log/security <10J>: size (Kb): 1 [100] --> skipping
/var/log/sendmail.st <10>: does not exist, skipped.
/var/log/utx.log <3>: --> will trim at Tue May  1 05:00:00 2018
/var/log/weekly.log <5J>: does not exist, skipped.
/var/log/xferlog <7J>: size (Kb): 1 [100] --> skipping
/var/log/daemon.log <7J>: does not exist, skipped.

注意最后一行:

/var/log/daemon.log <7J>: does not exist, skipped.

在这种情况下,有助于调试并发现syslogd中可能缺少该条目,可以通过将此行添加到以下内容来修复/etc/syslog.conf

daemon.notice                        /var/log/daemon.log

推荐阅读