10
votes

I can see the logs in the AWS Console under Codedeploy, when I select the deployment and then click choose events, but they appear to be truncated. If I SSH into the instance, where are those codedeploy deployment logs located?

I see logs in /var/log/aws/codedeploy-agent, but the logs there don't match what's in CodeDeploy.

I'm running on Amazon Linux.

4

4 Answers

26
votes

I've figured it out. The deployment logs are found in:

/opt/codedeploy-agent/deployment-root/deployment-logs/codedeploy-agent-deployments.log

Each deployment also keeps it's logs in:

/opt/codedeploy-agent/deployment-root/88f9d1cf-4ee4-4b0c-9458-b1d41b8d4b48/d-TTUV9E8BG/logs/script.log where 88f9d1cf-4ee4-4b0c-9458-b1d41b8d4b48/d-TTUV9E8BG is different for each deployment.

On windows this appears to be:

C:\ProgramData\Amazon\CodeDeploy<DEPLOYMENT-GROUP-ID><DEPLOYMENT-ID>\logs\scripts.log

Source: https://github.com/aws/aws-codedeploy-agent/issues/8

6
votes

Linux Deployment Logs (Not the same as original answer):

/var/log/aws/codedeploy-agent/codedeploy-agent.log

Linux Script Logs:

/opt/codedeploy-agent/deployment-root/deployment-group-ID/deployment-ID/logs/scripts.log

https://docs.aws.amazon.com/codedeploy/latest/userguide/deployments-view-logs.html

4
votes

If you've found this question and you're looking for Windows logs, they are next to the userdata logs, in

C:\ProgramData\Amazon\CodeDeploy\log\
C:\ProgramData\Amazon\CodeDeploy\deployment-logs\codedeploy-agent-deployments.log

The \log\ folder contains the logs for the agent itself, showing that it's running and checking for updates. The deployment-logs contains the output of the deployment scripts, that's probably the one you want.

(programData is a hidden folder which requires administrative permissions)

2
votes

log in to your ec2 instance with the command

ssh -i {KeyPair.pem-locations to keys file here} [email protected]{your instance ip here}

go to below location, you will have logs here

/opt/codedeploy-agent/deployment-root/deployment-logs/codedeploy-agent-deployments.log

use the command

cat codedeploy-agent-deployments.log

with this you can open the log file in the commandline itself if your ec2 is a linux instance and if you are working on linux. copy it and paste it somewhere in your local machine so you can further explore the logs without any hassle.

`