Recently, I set up a new jail to handle my email and so I wanted to increase the number of rotated maillogs to 60 days (from the default 7). I tried to be clever by creating /usr/local/etc/newsyslog.conf.d/maillog.conf with the following line in it: /var/log/maillog 640 60 * @T00 JC and I keeping the maillog entry in /etc/newsyslog.conf alone. I assumed that the .d snippet would *override* the line from the main config file. What ended up happening was that *every* rotated maillog would look like: # bzcat maillog.20241019T000000.bz2 Oct 19 00:00:00 smtp newsyslog[33052]: logfile turned over Oct 19 00:00:00 smtp newsyslog[33052]: logfile turned over I believe that what happened is that newsyslog rotated the log twice every night - first based on the /etc/newsyslog.conf rule and then based on the /usr/local/etc/newsyslog.conf.d/maillog.conf rule. Since there were no log messages from postfix during the few milliseconds between rotations, the log only had the newsyslog markers when it got rotated for the second time and the actual log contents from the first log rotation of the night got lost. (I like timestamp-based log rotation, and so my /etc/crontab has `newsyslog -t DEFAULT`. It is possible that using the regular integer suffixes would have resulted in every-other-log still containing the log messages from the day. I haven't tested it.)
What is the actual bug you are trying to report?
Specifying the same log file name multiple times (across newsyslog.d/*.conf snippets) doesn't result in a single log rotation - it results in the same log getting rotated multiple times resulting in log data loss since the previous rotated log is overwritten by the second/third/etc. rotation.
Btw, this multi-rotation happens completely silently and there is no indication that something like that is happening. I expected one of these instead: 1. take the last entry for each log file name 2. warn if there are multiple instances of the same log file name
(In reply to Josef 'Jeff' Sipek from comment #3) Well, neither is documented in the manpage, I'd say that the behavior you have is undefined.
Agreed. It is currently undefined. IMO it'd be a good thing to allow the "overriding" behavior to make config management easier - rewriting existing files is always more painful than being able to drop a fragment into a .d directory. So, I suppose this ticket is a request to define a behavior - I don't really care how it is defined, but (the current undefined behavior of) silent log file loss is a bad.
I've run into this too. The "overriding" behavior that is desired would be nice because then we don't have to manage /etc/newsyslog.conf to change how e.g., maillog is rotated. Documenting the current behavior in the man page should be the first step
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=64e612b46290617ec753b4ee6ec633a3724940e3 commit 64e612b46290617ec753b4ee6ec633a3724940e3 Author: Alexander Ziaee <ziaee@FreeBSD.org> AuthorDate: 2026-02-12 14:14:47 +0000 Commit: Alexander Ziaee <ziaee@FreeBSD.org> CommitDate: 2026-02-12 14:14:48 +0000 newsyslog.conf.5: Add a CAVEAT PR: 282639 MFC after: 3 days Reviewed by: michaelo Differential Revision: https://reviews.freebsd.org/D55122 usr.sbin/newsyslog/newsyslog.conf.5 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Okay, thanks for tagging me! I documented this in the reference manual. Current policy is that "someone else should improve this" bugs are not bugs and impose a burden on bugmeister, so I'm going to close it as fixed. If you think this is an error please reopen.
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=817f0b88ff3f03d580e187d2c5910c21c88c33c9 commit 817f0b88ff3f03d580e187d2c5910c21c88c33c9 Author: Alexander Ziaee <ziaee@FreeBSD.org> AuthorDate: 2026-02-12 14:14:47 +0000 Commit: Alexander Ziaee <ziaee@FreeBSD.org> CommitDate: 2026-02-16 00:23:30 +0000 newsyslog.conf.5: Add a CAVEAT PR: 282639 MFC after: 3 days Reviewed by: michaelo Differential Revision: https://reviews.freebsd.org/D55122 (cherry picked from commit 64e612b46290617ec753b4ee6ec633a3724940e3) usr.sbin/newsyslog/newsyslog.conf.5 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=17da2d24b7af843739be6b3d9ce244f511cde2ee commit 17da2d24b7af843739be6b3d9ce244f511cde2ee Author: Alexander Ziaee <ziaee@FreeBSD.org> AuthorDate: 2026-02-12 14:14:47 +0000 Commit: Alexander Ziaee <ziaee@FreeBSD.org> CommitDate: 2026-02-16 01:03:29 +0000 newsyslog.conf.5: Add a CAVEAT PR: 282639 MFC after: 3 days (resolved merge conflicts) Reviewed by: michaelo Differential Revision: https://reviews.freebsd.org/D55122 (cherry picked from commit 64e612b46290617ec753b4ee6ec633a3724940e3) usr.sbin/newsyslog/newsyslog.conf.5 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)