I am doing a schedule and need to use multi-threading to call up the stored procedure or SQL in the program and record the log, and record the execution information in the log. However, according to the information, logging is multi-process safe and multi-thread unsafe. Is there any way to write logs to the same log file in multiple threads? thank you all
It is recommended to use the producer-consumer model. The producer writes logs to the queue through multiple threads, and the consumer takes the logs from the queue and writes them into the log
Is it multi-process or multi-thread?
If there are multiple processes, it is recommended to write to stderr, and then the manager (such as systemd or supervisord) can write the file uniformly.