dongshuan8722 2017-03-10 18:10
浏览 215
已采纳

如何登录Amazon Web Service(AWS)?

I have a project built in Golang and deployed on a Docker instance in AWS.

Internally I create a log file where the program write several logs.

How can I access that log file?

Is there another correct way to logging?

Thanks

  • 写回答

4条回答 默认 最新

  • duanlu4371 2017-03-14 02:22
    关注

    Thanks for reply.

    After a while looking for the solution to the problem, I found it!

    Firstly, I needed to mount the file that is inside the instance in the docker-host.

    To do this I add a Json file in the root folder of my project called Dockerrun.aws.json ( http://docs.aws.amazon.com/es_es/elasticbeanstalk/latest/dg/create_deploy_docker_image.html#create_deploy_docker_image_dockerrun )

    That is the file that declares the shared folder (volumes) (beetwen docker-host and instance) where I save my log file . This line is equivalent to adding -v flag in the docker run command (https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-data-volume). I do this this way because I can not add mount to a running instance and i cant stop it by ssh.

    {
      "AWSEBDockerrunVersion": "1",
      "Volumes": [
      {
        "HostDirectory": "/var/log/",
        "ContainerDirectory": "/go/src/app/log"
      }
      ]
    }
    

    Then to tell aws that I want to download my log file when I request records. (Tail (last 100 lines), bundle or rotate) I add these files to the .ebextension folder in my project directory. ( http://docs.aws.amazon.com/en_us/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-extend )

    Log_bundle.conf

    Files:
    "/opt/elasticbeanstalk/tasks/bundlelogs.d/log_bundle.conf":
        Mode: "000755"
        Owner: root
        Group: root
        Content: |
          /var/log/application.log
    

    Log_rotate.config

    Files:
    "/opt/elasticbeanstalk/tasks/bundlelogs.d/log_rotate.conf":
        Mode: "000755"
        Owner: root
        Group: root
        Content: |
          /var/log/application.log
    

    Log_tail.config

    Files:
    "/opt/elasticbeanstalk/tasks/publishlogs.d/log_tail.conf":
        Mode: "000755"
        Owner: root
        Group: root
        Content: |
          /var/log/application.log
    

    Finally, I dont try Amazon Could Watch but is the next step.

    Regards

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题