[英]AWS Elastic Beanstalk NodeJS and logs
I want to migrate my NodeJS project from single EC2 to ElasticBeanstalk.我想将我的 NodeJS 项目从单个 EC2 迁移到 ElasticBeanstalk。 In my current code I use the dependency log4js which create a log file on the filesystem.
在我当前的代码中,我使用依赖关系 log4js 在文件系统上创建一个日志文件。 On EC2 this works create but what is the best way in ElasticBeanstalk to log something?
在 EC2 上,这可以创建,但 ElasticBeanstalk 中记录某些内容的最佳方式是什么? If I download the generated logs from ElasticBeanstalk my custom log file from log4js isn't present.
如果我从 ElasticBeanstalk 下载生成的日志,我的 log4js 自定义日志文件不存在。
Best regards此致
In order to see the logs you can:要查看日志,您可以:
You can see a few different log files there.您可以在那里看到几个不同的日志文件。
I believe that logs you write using log4js in Node.js will be under:我相信您在 Node.js 中使用 log4js 编写的日志将位于:
/var/log/nodejs/nodejs.log
/var/log/nodejs/nodejs.log
I like to ssh into the elastic beanstalk instance and tail the log to see it updating "live" (when I use my server).我喜欢通过 ssh 进入弹性 beanstalk 实例并跟踪日志以查看它更新“实时”(当我使用我的服务器时)。 to do it run the following:
要做到这一点,请运行以下命令:
eb ssh
ssh
tail -n 50 -f /var/log/nodejs/nodejs.log
tail -n 50 -f /var/log/nodejs/nodejs.log
The above log path depends on the type of the EC2 .上述日志路径取决于 EC2 的类型。 on Linux 2 it is:
/var/log/web.stdout.log
在 Linux 2 上它是:
/var/log/web.stdout.log
In general, when you deploy to Elastic Beanstalk linux environment your app will be under:通常,当您部署到 Elastic Beanstalk linux 环境时,您的应用程序将位于:
/var/app/current
/var/应用程序/当前
Try finding your log files under this path- they will have the same name as when you run the app locally.尝试在此路径下找到您的日志文件 - 它们的名称与您在本地运行应用程序时的名称相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.