Search code examples
node.jssails.jslog4js-node

Logging server status


I am currently adding logs in my application using log4js (not the default sails logger). I'd like to be able to keep track of the server status : when it's up and down. Where should I put the logs to be able to know when the server is down?

Thanks for bringing me out of darkness


Solution

  • I didn't test it, but if you want to write a log when the server is shutting down you could try to use the exit event of the process object

    var log4js = require('log4js');
    process.on('exit', function(code) {
      var logger = log4js.getLogger();
      logger.info("End of the process");
    });