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
给我你的怀抱2017-05-27 17:41:32
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
高洛峰2017-05-27 17:41:32
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.