You could certainly use something like
siege -- but it seems like a lot of work for little benefit, at least given what you're trying to accomplish.
If I were you I'd just create some random/empty files. Give them the right name and put them in the right place and
logrotate should do its job normally -- it doesn't care at all about what the contents of the files are, which makes sense since log files may look different for different services or even for different users of the same service.
At its simplest, something like this might be enough for you:
Or if you wanted to get a tiny bit fancier you append the date/time to your log file so you could track when the logs are actually getting rotated. You could put something like this to your crontab, having it run every minute/hour/whatever:
echo `date` >> /var/log/nginx/access.log
I suppose that if you wanted to have your fake logs look more like real logs you could do something like this:
# Generate Random IP Address
IP_ADDRESS="$(( $RANDOM % 254 + 1 )).$(( $RANDOM % 254 + 1 )).$(( $RANDOM % 254 + 1 )).$(( $RANDOM % 254 + 1 ))"
# Get the current date/time
# Append a fake entry to the log file
echo "$IP_ADDRESS - - [$NOW +0000] \"GET / HTTP/2.0\" 200 5316 \"https://example.com/\" \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36\" \"-\"" >> /var/log/nginx/access.log
The above will create lines that look like this, using a randomly generated IP address and the current date/time:
184.108.40.206 - - [23/Sep/2020:16:07:54 +0000] "GET / HTTP/2.0" 200 5316 "https://example.com/" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" "-"
However, making your logs look like real logs seems like overkill to me, and to my way of thinking it will just make debugging more complicated than just appending the date/time to the file.
All that said, if you're rotating logs based on file size, you could use something like the
truncate command to generate files of various sizes. For instance, this command creates a 4MB file:
truncate -s 4M /var/log/nginx/access.log
Clearly none of these options actually simulates Nginx logs, but again, that's not really necessary to test
logrotate. Finally, you might also find it helpful to use the
--force option for
logrotate so that you can see immediately how your logs will be rotated. (See: https://www.shellhacks.com/logrotate-force-log-rotation/).