Can't rotate fail2ban log with newsyslog in FreeBSD 15

I'm having trouble rotating security/py-fail2ban log with newsyslog, no more logging after turning over.

Anyone rotating fail2ban sucessfully with newsyslog?

All these fails in /usr/local/etc/newsyslog.conf.d/daemons.conf:
Code:
/var/log/fail2ban.log root:wheel 600 14 * $D04 J
/var/log/fail2ban.log root:wheel 600 14 * $D04 JC /var/run/fail2ban/fail2ban.pid 30
/var/log/fail2ban.log root:wheel  600 14 * $D04 JR /usr/local/etc/scripts/fail2ban-logrotate.sh

fail2ban-logrotate.sh (also fails):
Code:
#!/bin/sh
/usr/local/bin/fail2ban-client flushlogs > /dev/null

/var/log/fail2ban.log - no more logging after turning over:
Code:
Apr 11 04:00:00 srv12 newsyslog[86857]: logfile turned over
2026-04-11 04:00:01,487 fail2ban.server [1302]: INFO rollover performed on /var/log/fail2ban.log

I have had a question before, and I got this working in FreeBSD 13.
But now I'm back to square one again.

Thanks,
 
As workaround i can propose you to use SYSLOG with facility local0

Edit/usr/local/etc/fail2ban.conf and change the logtarget to logtarget = SYSLOG[facility=local0]

Then create /etc/syslog.d/fail2ban.conf
Code:
local0.*    /var/log/fail2ban.log
Note: between local0.* and the file path you have "TAB" not spaces"

Then configure your newsyslog to rotate the logfile as you wish. You need to precreate the fail2ban.log file using touch /var/log/fail2ban.log and let the newsyslog to create the file after the rotation with "JC" flag.
Then reload the syslogd service syslogd reload
And restart the fail2ban service fail2ban restart

Edit:
For some reason the fail2ban syslog ident name programname doesn't work and i was unable to make it work using "!fail2ban-server" in syslog.d that's why i switch to different facility name (default was daemon) and route the log to a separate file instead of using the /var/log/daemon.log
 
Back
Top