Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi threaded access to files #163

Open
BrightShadow opened this issue Feb 2, 2023 · 3 comments
Open

Multi threaded access to files #163

BrightShadow opened this issue Feb 2, 2023 · 3 comments

Comments

@BrightShadow
Copy link

Hello there. I have a question. Will the streamroller work for e.g. 200 of instances of the same server/process writing to the same logs folder? I mean, will the file rotation and all file data appending work in that case?
I have a server which runs in dockerized environment and we can have up to 200 instances of server. I want to use your solution for logging from all instances in parallel, logs should be stored in one place, one file.

@nomiddlename
Copy link
Collaborator

Streamroller works by keeping track of how many bytes it has written to a file (for file rotation by size anyway), so multiple processes writing to the same file will all be trying to rotate it at different times. For date rotation, they will all be trying to rotate the files at the same time. So, in short, I don't think this will work. In general though, never mind if streamroller is involved or not, multiple processes writing to the same file is a bad idea - how will you avoid them trying to write at the same time?

@BrightShadow
Copy link
Author

Thanks for information, that's what I thought. I agree this kind of writing to single file from multiple threads isn't a good idea. I was just wondering if you have some multiprocess synchronization / locking etc. Thanks again.

@nomiddlename
Copy link
Collaborator

Within a single node.js application, which can have multiple child processes, we do manage the writing of logs with a single process (the individual processes in a node.js cluster delegate the output to the main process). But log4js doesn't attempt to synchronise or lock files, and assumes it is the only process writing to the files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants