This is a simplified diagram that shows the interactions between the main components of a typical web application production environment.

The users make requests to the web application. In order to serve the requests, the web application needs information from a database, in this case, the databased being used is PostgreSQL, so it makes queries to it.

The PostgreSQL database server computes the queries, returns back data, but at the same time, it also writes to log files on disk.

The log files are being rotated on a daily basis. We employ rotating logs to avoid running into low disk-space situations on productive systems. And generally, the rotated logs are sufficient to troubleshoot a problem signaled by a monitoring system.

Each day has its own log file. Log lines are accumulated in the log file according to the day of the week when the logged operation was executed (the most common operation would be a query). The entire cycle continues for each day, and after one week, on the same day, the log file is truncated, and then it's written to again.