gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 02:07:38 25 4
gpt4 key购买 nike

我对使用 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)

最佳答案

好吧,经过研究,我发现我可以控制这个。因为我只是在执行抛出错误,所以它没有显示时间戳。有人建议我使用一些不同的日志记录包,但这是我最有可能使用的一个:

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

如果大家有更好的建议请告诉我。

关于node.js - AWS Elastic Beanstalk Node.js 日志没有时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43617549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com