简体   繁体   English

应用程序记录弹性豆茎

[英]Application Logging for elastic beanstalk

I have Spring MVC application running on aws ec2. 我在aws ec2上运行了Spring MVC应用程序。 Now I have decided to move to aws elastic beanstalk and yet exploring it before migrating current application. 现在我决定转移到aws弹性beanstalk,然后在迁移当前应用程序之前进行探索。 I had few questions regarding persistent storage and application logging. 我对持久存储和应用程序日志记录的问题很少。

My question could be naive but please bear with it :) 我的问题可能很幼稚,但请耐心等待:)

I am using log4j for application logging. 我正在使用log4j进行应用程序日志记录。 Log4j appends logs at specified location on hard drive. Log4j将日志附加到硬盘驱动器上的指定位置。 As elastic beanstalk has no persistent storage (storage will be deleted once instance is terminated) and instances may grow/shrink based on the load rules. 由于弹性beanstalk没有持久存储(一旦实例终止,存储将被删除),实例可能会根据加载规则增长/缩小。

So I am stuck at the following 所以我被困在以下

  1. How would I configure log4j for appending the logs. 如何配置log4j以附加日志。
  2. If I were to stick to current log4j implementation, how would I make sure that directory structure be created when an instance is launched( I am assuming no code changes in the application) 如果我坚持当前的log4j实现,我将如何确保在启动实例时创建目录结构(我假设应用程序中没有代码更改)
  3. If I go with socketappender from log4j then how would I distinguish between files from different instances. 如果我从log4j开始使用socketappender,那么我如何区分来自不同实例的文件。

I have been going through articles describing use of .ebextensions directory. 我一直在阅读描述.ebextensions目录使用的文章。 I tried using basic .conf files provided by AWS to tail logs to S3 but no success for my application logs. 我尝试使用AWS提供的基本.conf文件将日志记录到S3,但我的应用程序日志没有成功。

Sample script to create application directory places under .ebextensions 用于在.ebextensions下创建应用程序目录的示例脚本

commands:
  01_create_dir:
    test: test ! -d "${DIR}"
    command: mkdir "${DIR}"

Referred links : 推荐链接:

EBS console displays apache logs for URL access. EBS控制台显示用于URL访问的apache日志。

I would like to know if there is any ready-made solution provided by AWS already that I failed to search. 我想知道AWS是否已经提供了我未能搜索的现成解决方案。

From http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html : 来自http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html

Standard output and error streams from processes started with a Procfile are captured in log files named after the process and stored in /var/log. 使用Procfile启动的进程的标准输出和错误流将在以进程命名的日志文件中捕获并存储在/ var / log中。 For example, the web process in the preceding example generates logs named web-1.log and web-1.error.log for stdout and stderr, respectively. 例如,前面示例中的Web进程分别为stdout和stderr生成名为web-1.log和web-1.error.log的日志。

Based on that, all you have to do is ensure log4j / logback outputs the logs you want to stdout, ie CONSOLE . 基于此,您所要做的就是确保log4j / logback输出您想要stdout的日志,即CONSOLE With Spring Boot this is the default behavior. 使用Spring Boot,这是默认行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 AWS Elastic Beanstalk 进行应用程序日志记录 - Application logging with AWS Elastic Beanstalk 使用 Logback 的 AWS Elastic Beanstalk 应用程序日志记录 - AWS Elastic Beanstalk Application Logging with Logback 使用Elastic Beanstalk Tomcat启用垃圾收集日志记录 - Enabling garbage collection logging with Elastic Beanstalk Tomcat 使用Elastic BeansTalk CLI部署Spring Boot应用程序 - Deploy Spring Boot application with Elastic BeansTalk CLI 将Java Web应用程序部署到Amazon Elastic Beanstalk - Deploying Java web application to Amazon Elastic Beanstalk 在Elastic Beanstalk上部署的Spring应用程序中的登录问题 - Login Issue in Spring Application Deployed on Elastic Beanstalk Elastic Beanstalk主机特定的应用程序配置 - Elastic Beanstalk host specific application configuration Elastic Beanstalk返回错误-Gradle / Java应用程序 - Elastic Beanstalk returning error - Gradle/Java Application 弹性 beantak 上的 Tomcat:如何更改弹性 beantalk 上的 server.xml 以禁用命令行参数的日志记录? - Tomcat on elastic beanstak: How to change server.xml on elastic beanstalk to disable logging of command line arguments? 将Spark-Java(Gradle,Maven)应用程序部署到AWS Elastic Beanstalk - Deploy Spark-Java (Gradle, Maven) application to AWS Elastic Beanstalk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM