1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerでpumaを起動したとき、pumaのログの他にproduction.logなどもCloudwatch Logsに転送する

Posted at

pumaが動くDockerコンテナでlog driverにawslogsを指定してCloudwatch Logsにログを送るようにしたが、production.logも転送したいと思った。

DockerのENTRYPOINT、CMDで実行されたスクリプトはpid=1で起動するようなのでproduction.logを/proc/1/fd/1へのシンボリックリンクにした。

  • Dockerfile
CMD /start.sh
  • /start.sh
ln -fs /proc/1/fd/1 /app/log/production.log
bundle exec puma -C config/puma.rb
  • Dockerのlogdriver設定

docker-compose.ymlの抜粋

 log_driver: awslogs
  log_opt:
    awslogs-group: hogehoge
    awslogs-region: リージョン
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?