-
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
Fails to log to file transport in Linux when used in http async responses #222
Comments
Yes, i have met the same issue on my Ubuntu, it seems that it happens in high frequency when try to write logs to a file transport in a callback function on Linux. |
+1 seeing this on Ubuntu x64 12.04 w/ Node v0.10.0 (and v0.9.8) |
i have the smae problem, for example in this code: var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
//new (winston.transports.Console)(),
new (winston.transports.File)({ filename: 'somefile.log' })
]
});
//logger.log('info', 'Hello distributed log files!');
//logger.info('Hello again distributed logs');
setTimeout(function(){
logger.info("from timeout");
logger.info("from timeout 2");
},100);
logger.log('info', 'Hello distributed log files!'); the calls in time out wil not bu flushed to the file.... i added this 2 calls in lib/winston/transports/file.js:447 self.emit('flush');
self.emit('logged'); after this: //
// When the stream has drained we have flushed
// our buffer.
//
self._stream.once('drain', function () {
self.emit('flush');
self.emit('logged');
}); that make the thing work... but im sure is not really ok... the problem is the drain event in the buffer is never emmited so, the opening flag is never set to false again... so... it thinks the file is still opening and doesnt try to fluash again... |
+1 I can confirm this bug as well. I'm currently using @javiern 's fix above, and it seems to work. As he says, the cause seems to be that the file is stuck in the 'opening' state because the drain event is never emitted. |
It's weird. It could the reason my log works on local dev env but doesn't work when running on AWS EC2. I'm gonna try the fix above. |
+1 same problem here. And also solved using @javiern fix! |
@indexzero, it very well could be. For a while now, the file transport seems to have held up despite my doubts (the original issue that caused my concern about that issue turned out to be unrelated), but I'll look at this. To be on the safe side we can always merge that reverted branch. |
Also getting very inconsistent / random logging with the winston file transport. With async code often log outputting is missing from the log file. |
Fixed in #446. Published in |
doesn't log to file for me for some reason. |
@chovy could you please double check you are on |
I was having a similar problem with the version 1.1.0, but the solution was simple and not related to winston: I just had to use "__dirname + '/logs/log_file.log'" instead of "./logs/log_file.log", and it started to create the files on the linux environment too (inside the "logs" folder in my project folder). var logger = require('winston'); |
@fernandoghisi : A small change to your answer that works for me : // Updated code Hope it helps. |
Hi,
Interestingly, winston does not log to the file transport on Linux when I try to log something in the http responses. I am using async and request packages in my implementation.
Please note that it works on Windows 8. I am using the same implementation in an Amazon EC2 Linux 64-bit instance and seeing the problem.
For instance:
yields this
The fourth line, "Inside of request callback" is missing in the log file.
Regards,
The text was updated successfully, but these errors were encountered: