plog icon indicating copy to clipboard operation
plog copied to clipboard

Does writing logs from multiple processes to the same log file at the same time cause problems

Open liuhao123t opened this issue 11 months ago • 5 comments

Does writing logs from multiple processes to the same log file at the same time cause problems

liuhao123t avatar Dec 26 '24 08:12 liuhao123t

Writing to the same file from multiple processes is atomic and cause no issues.

What's problematic is log rotation as it requires inter-process synchronization. Also different processes may have different log rotation parameters. So if you do not use log rotation everything will be fine.

SergiusTheBest avatar Dec 26 '24 10:12 SergiusTheBest

Writing to the same file from multiple processes is atomic and cause no issues.

What's problematic is log rotation as it requires inter-process synchronization. Also different processes may have different log rotation parameters. So if you do not use log rotation everything will be fine.

What if I set the same log rotation parameters for all my processes,one process write fast ,the other one write slow, will they rotate at the same time?

liuhao123t avatar Dec 26 '24 10:12 liuhao123t

@liuhao123t No, it won't work as there is no inter-process synchronization. So they may start rotating at the same time, or one after another.

SergiusTheBest avatar Dec 26 '24 10:12 SergiusTheBest

Writing to the same file from multiple processes is atomic and cause no issues.

What's problematic is log rotation as it requires inter-process synchronization. Also different processes may have different log rotation parameters. So if you do not use log rotation everything will be fine.

How to disable log rotation?

Chris55 avatar Apr 15 '25 14:04 Chris55

How to disable log rotation?

It's disabled by default. Unless you set log files number and log file max size.

SergiusTheBest avatar Apr 15 '25 15:04 SergiusTheBest