AWS Elastic Beanstalk NodeJS和日志 [英] AWS Elastic Beanstalk NodeJS and logs

查看:94
本文介绍了AWS Elastic Beanstalk NodeJS和日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将NodeJS项目从单个EC2迁移到ElasticBeanstalk.在当前代码中,我使用依赖项log4js在文件系统上创建一个日志文件.在EC2上可以创建,但是在ElasticBeanstalk中记录某些东西的最佳方法是什么?如果我从ElasticBeanstalk下载生成的日志,则我的log4js自定义日志文件不存在.

I want to migrate my NodeJS project from single EC2 to ElasticBeanstalk. In my current code I use the dependency log4js which create a log file on the filesystem. On EC2 this works create but what is the best way in ElasticBeanstalk to log something? If I download the generated logs from ElasticBeanstalk my custom log file from log4js isn't present.

最诚挚的问候

推荐答案

要查看日志,您可以:

  • 按下您的弹性beantalk环境
  • 按日志"(在左侧)
  • 按请求日志"(通常只需要最后100行即可)并下载文件.

您可以在其中看到一些不同的日志文件.

You can see a few different log files there.

我相信您在Node.js中使用log4js编写的日志将位于以下位置:

I believe that logs you write using log4js in Node.js will be under:

/var/log/nodejs/nodejs.log

/var/log/nodejs/nodejs.log

我喜欢ssh进入弹性beantalk实例,并尾随日志以查看其更新实时"日志.(当我使用服务器时).为此,请运行以下命令:

I like to ssh into the elastic beanstalk instance and tail the log to see it updating "live" (when I use my server). to do it run the following:

eb ssh

eb ssh

tail -n 50 -f/var/log/nodejs/nodejs.log

tail -n 50 -f /var/log/nodejs/nodejs.log

上面的日志路径取决于EC2的类型.在Linux 2上,它是:/var/log/web.stdout.log

The above log path depends on the type of the EC2. on Linux 2 it is: /var/log/web.stdout.log

通常,当您部署到Elastic Beanstalk linux环境时,您的应用程序将位于:

In general, when you deploy to Elastic Beanstalk linux environment your app will be under:

/var/app/current

/var/app/current

尝试在此路径下查找日志文件-它们的名称与在本地运行应用程序时的名称相同.

Try finding your log files under this path- they will have the same name as when you run the app locally.

这篇关于AWS Elastic Beanstalk NodeJS和日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆