从手册:
每个配置文件都可以设置全局选项(本地定义覆盖全局选项,后面的定义覆盖早期的定义)并指定要轮换的日志文件。
如果我正确理解定义,/path2/dir1/.log
从第一个块设置的选项将被结束块设置覆盖。里面有很多目录/path2/
,我不想把它们单独写出来。
/path1/*/*.log
/path2/*/*.log
/path3/*/*.log
/path4/*/*.log
/path5/*/*.log
{
size 100k
rotate 10
compress
dateext
postrotate
service rsyslog restart >/dev/null 2>&1 || true
endscript
}
/path3/dir1/*.log
{
size 200k
rotate 50
compress
dateext
postrotate
service rsyslog restart >/dev/null 2>&1 || true
endscript
}
运行测试时我不相信我的理解。看来在这个测试中,这dir1
将由第一组选项处理,然后再由第二组选项处理。
logrotate -d mylogconf 2>&1 | less
reading config file mylogconf
Allocating hash table for state file, size 15360 B
Handling 3 logs
rotating pattern: /path1/*/*.txt
after 1 days (360 rotations)
empty log files are not rotated, old logs are removed
No logs found. Rotation not needed.
rotating pattern: /path2/*/*.txt
/path3/*/*.txt
153600 bytes (40 rotations)
empty log files are not rotated, old logs are removed
No logs found. Rotation not needed.
rotating pattern: /path3/dir1/*.txt
204800 bytes (50 rotations)
empty log files are not rotated, old logs are removed
No logs found. Rotation not needed.
如果我是正确的,那么我认为我的conf文件需要看起来像这样:
/path1/*/*.log
/path2/*/*.log
/path3/dir2/*.log
/path3/dir3/*.log
/path3/dir4/*.log
{
size 100k
rotate 4
}
/path3/dir1/*.log
{
size 200k
rotate 50
}