5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LaravelのログをCloudwatchに飛ばす

Posted at

前提

  • Ubuntu24.04

インストール

wget https://s3.ap-northeast-1.amazonaws.com/amazoncloudwatch-agent-ap-northeast-1/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb

※EC2のアーキテクチャを確認
https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html

sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
vim /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/laravel.json

ステータス

systemctl status amazon-cloudwatch-agent.service

起動

systemctl start amazon-cloudwatch-agent.service

自動起動

sudo systemctl enable amazon-cloudwatch-agent

file_path部分はLaravelが配置されているパスに変更してください

{
    "agent": {
        "run_as_user": "root"
    },
    "logs": {
        "logs_collected": {
            "files": {
                "collect_list": [
                    {
                        "file_path": "/var/www/html/storage/logs/laravel*log",
                        "log_group_name": "/ec2/laravel-log",
                        "log_stream_name": "laravel-log-%Y-%m-%d"
                    }
                ]
            }
        }
    }
}

5
0
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
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?