When does PostgreSQL write logs? I turned on the configuration parameter log_planner_stats and would like to examine the details in log. But the log file is empty. It seems all the log files are changed at 12:00am of a day. Does PostgreSQL only writes log at that time? Is there any way to see the real-time log? BTW, I checked the log files in the directory pg_log which I guess is the right directory to find logs.
No, if PostgreSQL writes logs, then it writes basically real-time.  For example, if you open a log file with less and press ShiftF, you will get the newly written rows flowing in.

That you don't see anything in the logs can be caused by a few things, but first be sure you have read through the relevant documentation and set up everything accordingly.  There and in postgresql.conf you can also check where the DB writes the logs and so on.  Be aware that some configuration options need server restart or DB reload to take effect.