-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Logs fail when multiple processes or timers log to same file #80
Comments
Give me a couple days to dig into this. Thanks |
Any update on this? |
That's... a lot. This was probably gist-worthy. |
Your node version is from an unstable ( and very old ) branch. You should be running at least node |
( please update your node and try to reconfirm issue ) |
Same Unit test failure. I used node 0.6.15 |
I just updated from winston 0.5.9 to 0.5.11 and re-ran the tests and the outcome was failure of the same test. So all of the following fail on the same test: |
@fquatro I'll put this simply: can you make the repro smaller? It's a bit much to parse; kind of like looking for a bug on a needle in a haystack |
Not sure if this is related really, but what approach should we take when multiple processes are logging to the same transport type/destination? At the moment the problem I'm seeing is near simultaneous log events are writing on top of each other, and so become unreadable. |
I'm using node 0.8.22 with winston 0.6.2. I'm using cluster and each of my node processes is writing to the same file transport. I set the file transport up with a maxsize of 1024576. Currently the server is writing to 2 log files at the same time (8 and 9), and all of the log files are above the size I specified: -rw-r--r-- 1 adam users 1382735 Apr 8 15:35 server1.log |
@2fours, it looks like winston never behaved the way you're expecting. |
Any progress on this? This is how my logs folder looks today: [adam@server logs]$ ls -ltr currently it's writing to server12 and server13 simultaneously. |
+1 on a fix for this. |
@2fours to support file logging correctly, winston would have to use the cluster module and pass all data to the master where it can safely be written to a single file. Unfortunately Winston doesn't care about Cluster/ concurrency. so, there are multiple Options to do it right. One way is to switch to a "real" log-server architecture. Maybe winstond, which I never tried, can help you here. The other Option is to use IPC or Transport that solves the issues by nature e.g. logging to a database or using a message broker. Here is a proof of concept (without winston): https://gist.github.com/HansHammel/19c2457fa8bb4c1cff2f |
@HansHammel you have nailed it. |
I created this test suite after experiencing missing log entries in my file transport. The console transport on the same Logger instance would contain all log entries. I attempted to mimic my original application's logging which created a Winston Logger in the node global namespace and added a file transport to the Logger. The application forked child processes and in the child processes created a Winston Logger in the node global namespace and added a file transport to the Logger. All file transports were configured with the same options and logged to the same file.
The vows suite (and dependent file) below will fail assertions. WinstonSuite.js and LogSub.js must reside in the same directory. The three parent vows contexts are executed in parallel. This is intentional. The order in which they finish is undefined and the results may vary from each execution. The suite consistently fails with "expected true, got false // WinstonSuite.js:85" for example:
··1st Vow - log does not contain "WinstonSuite 1st Topic: Log Test 0 random 5UasDeNJpH"
✗
should log all delayed messages
✗ to file
» expected true, got false // WinstonSuite.js:86
✗ Broken » 2 honored ∙ 1 broken (15.114s)
System Information
Mac OS X 10.6.8
$ node --version
v0.5.4
$ npm list
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
└── [email protected]
WinstonSuite.js
LogSub.js
The text was updated successfully, but these errors were encountered: