From the manual:
> Each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones) and specify logfiles to rotate.
If I understand the definition correctly,
/path2/dir1/.log
options set from the first block will be overwritten by the end block settings. There are a number of dirs that are in /path2/
and I don't want to write them out individually.
/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
}
When running test I don't trust my understanding. It seems that in this test that dir1
would have been handled by the first set of options and then again with the 2nd set of options.
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.
If I am correct, then I think my conf file needs to look something like this:
/path1/*/*.log
/path2/*/*.log
/path3/dir2/*.log
/path3/dir3/*.log
/path3/dir4/*.log
{
size 100k
rotate 4
}
/path3/dir1/*.log
{
size 200k
rotate 50
}
Asked by Jon
(1 rep)
Mar 28, 2024, 11:22 AM
Last activity: Mar 28, 2024, 08:08 PM
Last activity: Mar 28, 2024, 08:08 PM