AWS Elastic Beanstalk NodeJS和日志

编程入门 行业动态 更新时间:2024-10-27 23:22:50
本文介绍了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和日志

本文发布于:2023-11-15 07:53:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1592552.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日志   Elastic   AWS   NodeJS   Beanstalk

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!