Log rotation in nginx works by monitoring the log file size or age. When the log file grows too large or reaches a time limit, the system renames the current log file to save it as an old log with a timestamp. Then, it creates a new empty log file for nginx to write fresh logs. To make nginx start writing to the new log file, the nginx service is reloaded. This process prevents log files from becoming too big and keeps logging smooth. The key steps are checking the log size, renaming the old log, creating a new log, and reloading nginx. Without reloading, nginx would continue writing to the old file. This cycle repeats as logs grow over time.