Log messages written in order?
See original GitHub issueIs it possible to have winston log its messages to a transport in order? It’s hard to read log files that aren’t sequential.
For example, I have a log output that included a date/time with milliseconds. (See below)
Is there a way to specify that each of the log messages be written in the order they occur? Thanks.
2016-02-25 21:34:07.671 INFO ...
2016-02-25 21:34:07.692 INFO ...
2016-02-25 21:34:07.690 DEBUG ...
2016-02-25 21:34:07.692 INFO ...
2016-02-25 21:34:07.691 DEBUG ...
2016-02-25 21:34:07.692 DEBUG ...
2016-02-25 21:34:07.692 DEBUG ...
NB: The code that generates the timestamps is at: https://github.com/winstonjs/winston/issues/802
Issue Analytics
- State:
- Created 8 years ago
- Reactions:7
- Comments:7
Top Results From Across the Web
Is chronological order of logging messages guaranteed?
Even then, log messages from the same thread will never be written out in a different order, they'll just be intermixed with messages...
Read more >Logging Best Practices: The 13 You Should Know - DataSet
Just as log messages can be written for different audiences, log messages can be used for different reasons. Even though troubleshooting is ...
Read more >1120894 – syslog messages very badly out of order in /var/log ...
rsyslog writes messages in the order it receives them and therefore can't enforce chronological order. With flat text files, there's not much ...
Read more >Messages "out of order segment" in /var/log/messages | Support
They are debugging messages from the IPv4 TCP/IP stack that indicate a data segment was received out of order (based on sequence number),...
Read more >Weird syslog order - ubuntu - Server Fault
It looks like the other logs except cron are OK. I added logging time by "something" script, not just cron and syslog. –...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@richb-hanover This is an issue with the default logging levels and their relationship with stdout and stderr. The culprit is: https://github.com/winstonjs/winston/blob/2.2.0/lib/winston/transports/console.js#L118-L122 and the associated option is declared at: https://github.com/winstonjs/winston/blob/2.2.0/lib/winston/transports/console.js#L34
The default stderr log levels are
error
anddebug
(defined as['error','debug']
), all other levels are routed to stdout. On the console, stdout and stderr are consolidated in the viewed output; these are separate output streams hence why they appear out of order from a timestamp perspective (think “async”). Obviously, if you’re sending stderr and stdout to separate files this quirk will not be apparent; again, it only surfaces when the streams are consolidated.As a work-around, you could set your Console transport’s
stderrLevels
option to an empty array which tells it to not log anything to stderr, and only to stdout. However, the side-effect to the work-around is that you can no longer distinguish between error and non-error output at the stream level. Be cautious to where you employ this.For example, when defining the console transport:
IMO, this is not a bug.
@zamnuts’s answer should be mentioned in readme.