How to do realtime logging in Meteor?

Anyone know how to do realtime logging in Meteor ?

For example streaming console.log to a web browser.

Is there a library that can do that ?

For example, I define the route /my-app/logs .

Then /my-app/logs will display the results of such console.log in realtime.

Like this : http://bellard.org/jslinux/

I’m looking for the same answer but haven’t found on yet.

The most I’ve come across are the following:

  • Two Meteor wrappers for Winston. Here’s the first and here’s the second. The second provides slightly more explanation and code than the first but just a little.
  • and this old [Winston blog post][3]
  • Also this one called [meteor-trail][4] and the viewer called [meteor trail monitor][5] but again they are old repos and I haven’t found any success.
  • Lastly, there is [Observatory][6] which evidently was once a free package but now is a coming paid service option.

Atmosphere also lists packages but there are little to no “actual” instructions on how to use these with Meteor. See here https:// atmospherejs.com/jag/pince?q=logging.

I feel this is a major issue that someone should have provided, but that is coming from a newbie walking in from the rails world.

If you (or anyone else) finds out more please let me know, too.

3: https:// meteorhacks.com/logging-support-for-meteor
4: https:// github.com/tbknl/meteor-trail
5: https:// github.com/tbknl/meteor-trail-monitor
6: http:// observatoryjs.com/

(Sorry for the link references on the bottom. The meteor forums only allow 2 links for new users … yes, this would have made much more sense if I could actually provide links to the references ??? crazy.)

Keep in mind that logging was one of the original use cases of Mongo, and is an area where it excels. Just pipe whatever you would normally send to console.log() to a mongo collection. Capped collections are particularly useful.

Yes @awatson1978 right.

Just use winston and set winston-mongodb as transport. So winston will store the logs to mongodb.

And on client just fetch the logs using collection, and you we will get realtime log.

Here is my winston config :

return new winston.Logger({
    transports: [    
        new winston.transports.MongoDB({
            db: mongoDbUrl,
            capped: true,
            collection: 'winstonLogs',
            handleExceptions: true
        })
    ],
    exitOnError: false
});
1 Like

Thanks @awatson1978 and @agusputra.

Coming from the Rails world, I’m just thinking of the need to log/output everything that happens between requests (like the debugged output from development mode or the log from a webserver ). I’ve a unique problem I’m trying to resolve in an app where there is no error but data isn’t getting saved to the db. For a newb coming over, having a log file to view output would help greatly.

Of course, maybe there is this type of functionality around and I just don’t know it.