AWS Elastic Beanstalk Node.js日志没有时间戳

时间:2017-04-25 17:42:31

标签: node.js amazon-web-services elastic-beanstalk

我很擅长使用AWS Elastic Beanstalk并在其上部署Node.js应用程序。我试图用我的Node应用程序调试问题,我注意到Node.js日志没有时间戳。如何向Node js日志添加时间戳。

这是当前日志的样子:

-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
    at Request.extractError (/var/app/current/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/var/app/current/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/app/current/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/app/current/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
/var/app/current/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

InvalidParameterValue: Missing required header 'To'.
    at Request.extractError (/var/app/current/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/var/app/current/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/app/current/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/app/current/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
/var/app/current/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

InvalidParameterValue: Missing required header 'To'.
    at Request.extractError (/var/app/current/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/var/app/current/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/app/current/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/app/current/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
/var/app/current/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

InvalidParameterValue: Missing required header 'To'.
    at Request.extractError (/var/app/current/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/var/app/current/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/app/current/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/app/current/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
/var/app/current/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

InvalidParameterValue: Missing required header 'To'.
    at Request.extractError (/var/app/current/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/var/app/current/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/app/current/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/app/current/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
/var/app/current/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

InvalidParameterValue: Missing required header 'To'.
    at Request.extractError (/var/app/current/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/var/app/current/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/app/current/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/app/current/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
/var/app/current/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

InvalidParameterValue: Missing required header 'To'.
    at Request.extractError (/var/app/current/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/app/current/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/var/app/current/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/app/current/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/app/current/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/app/current/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/var/app/current/node_modules/aws-sdk/lib/sequential_executor.js:115:18)

1 个答案:

答案 0 :(得分:0)

好的研究后我发现我可以控制它。因为我只是在做throw error,所以它没有显示时间戳。我被建议使用几个不同的日志包,但这是我最有可能的一个:

https://github.com/starak/node-console-stamp/

如果有人有任何更好的建议,请告诉我。