rsyslog server, logrotate and router.log

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 834
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Wed Sep 03, 2025 21:26    Post subject: rsyslog server, logrotate and router.log Reply with quote
I have had my XR500 sending its syslog to an rsyslog server, which is a Raspberry Pi also serving as the local PiHole DNS server and more. This works fine, but ....

over time the router.log file keeps growing and growing, of course, until today it reached 300 Mb in size.
I figured it is time to set up logrotate for router.log on the rsyslog server.

Using the following settings
/var/log/router.log
{
daily
missingok
create 0644 root root
rotate 7
compress
notifempty
delaycompress
}

logrotate indeed rotates router.log and creates the new file.

However, the router persists in writing to the rotated file router.log.1 ...
Eventually this is bound to create a problem, when router.log.1 is rotated to router.log.2.gz (the next day ...).

Rebooting the router doesn't seem to help.

How should I change the logrotate settings on the rsyslog server to have the router notice the new file?

Rebooting both devices appeared to make the router write to router.log again, but it is hardly a practical or sensible solution.
Sponsor
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 16562
Location: Texas, USA

PostPosted: Wed Sep 03, 2025 22:40    Post subject: Reply with quote
https://duckduckgo.com/?q=rsyslog+writes+to+rotated+log+file+after+rotation+and+not+to+new+file

https://github.com/rsyslog/rsyslog/issues/3952

https://computingforgeeks.com/perform-proper-rsyslog-logs-rotation-using-logrotate/

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
RSS feed for DD-WRT releases (2025)
RSS feed for DD-WRT releases (2024)
RSS feed for DD-WRT releases (2023)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 834
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Fri Sep 05, 2025 11:53    Post subject: Reply with quote
@kernel-panic69:
Thanks! This helped a lot. I got rsyslog and logrotate sorted out.

Files related to rsyslog and logrotate as I have them now:

/etc/logrotate.d/router:

/var/log/router.log
{
daily
missingok
create 0644 root root
rotate 7
compress
notifempty
delaycompress
postrotate
/usr/bin/systemctl kill -s HUP rsyslog.service >/dev/null 2>&1 || true
endscript
}

The postrotate command line replaces the 'rsyslog-rotate' script that is also used in the default logrotate.d files for rsyslog. It didn't work for the router.log. The clause with HUP as above works.

Below /etc/rsyslog.d/routerlog.conf (filename can be any valid name).
This conf file sets the file name for the log messages sent by the router on 192.168.1.1 through port 514 ...

#$template NetworkLog, "/var/log/router.log"
#:fromhost-ip, isequal, "192.168.1.1" -?NetworkLog
#& STOP

#$template routerlog, "/var/log/router.log"
#if $fromhost-ip startswith "192.168.1.1" then -?routerlog
#& stop

# Yet another form of syntax ...
if ($fromhost-ip == "192.168.1.1" ) then /var/log/router.log

Having different forms of filter clauses on different rsyslog servers is confusing. I found and tried the above which originated from different sources and all appear to work. Take your pick.
There are many instances of the same Rsyslog documentation on the internet, but I found it to be very complicated to figure out - felt like reading the 'Revised report on Algol 60' Wink and almost no simple examples or recent tutorials.

In addition you need to have uncommented the below lines in /etc/rsyslog.conf:

# provides UDP syslog reception
module(load="imudp")
input(type="imudp" port="514")

# provides TCP syslog reception
module(load="imtcp")
input(type="imtcp" port="514")

/etc/logrotate.conf is as installed.
I think this covers the files involved (my rsyslog servers run Raspberry Pi OS i.e. linux).
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum