freebsd newsyslog.conf.d set archive dir

时间:2018-04-24 11:04:10

标签: freebsd logrotate

在FreeBSD上,我有一个名为

的文件

my_site

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

文件my_site的内容如下所示:

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

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

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

1 个答案:

答案 0 :(得分:2)

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

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