Hapi.js Ops Log Management

If your Hapi.js server is using the Good Plugin for operations logs, you might want to know how to throttle the output. By default, Good spits out logs every 15 seconds. I really didn’t need ops info that frequently.

Semi-Obnoxious Ad : If you need a messaging app for your young kids, please consider Kids In Touch

After a bit of digging, I finally figured out how to achieve this. Just include this in your index.js after you’ve configured the server.

var loggingOptions = {
    "subscribers"   : {
        "console"   : [ "ops", "request", "log", "error" ]
    },
    "opsInterval" : 45000 // reduces ops logging to every 45 seconds
};

server.pack.require("good", loggingOptions, function( err ) {

    if( err ) throw err;

});

Now, you’ll get a nice output of logging every 45 seconds.

40528/154637.60, ops, memory: 44M uptime (seconds): 181.12350792437792
140528/154722.68, ops, memory: 44M uptime (seconds): 226.13181624002755
40528/154807.71, ops, memory: 44M uptime (seconds): 271.13441762700677
140528/154852.116, ops, memory: 44M uptime (seconds): 316.1794057562947
40528/154937.156, ops, memory: 45M uptime (seconds): 361.2195966159925
140528/155022.192, ops, memory: 45M uptime (seconds): 406.2552084196359