How can I generate Nginx log file data for one or more test (burner) domains on a test server? I want to essentially mimic a live website with regular traffic being logged but without the provision of a legit website.

I have started learning about logrotate and I am adapting it for the sites on my servers. In order to more fully understand how it works, I am ideally looking to replicate log file entries as if the test domains are live sites, without opening the domains up to a larger audience since they're essentially disposable domains for this purpose.

I have full (root) access to my VPS, I have Nginx set up as I want it, the test domains are all web-side rather than internal, and I have log files that currently just get bigger as time progresses…hence the need for logrotate.

I do not need a benchmarking, concurrency or load testing tool in the traditional sense as I don't want to overwhelm the server, so something like ab or siege that can run in drip-drip-drip mode might be a route to investigate.

1 Answer 1


You could certainly use something like ab or 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:

touch /var/log/nginx/access.log

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
NOW=$(date +"%d/%b/%Y:%H:%M:%S")
# 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: - - [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/).

Good luck!

  • 2
    This is your third answer here and like the other two it is extremely high quality. Thank you for taking the time to write such good answers and welcome to this site! Commented Sep 23, 2020 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.