amazon-web-servicesamazon-s3aws-cli

AWS CLI - Saving the full output as a log file


I am using the aws s3 cp command to upload files to my s3 bucket. I am using windows cmd for this and when I run the following command:

aws s3 cp "logs.txt" s3://test/logs.txt --debug > ./log_test.txt

With the debug flag I see a lot of relevant information which is showed in the cmd window but when I open the log_test.txt file I can only see one line (maybe not even one).

Is there a way to save the full output showed in my cmd screen into a file? This issue also happens when an error occurs. So if my file is not uploaded correctly I can't debug what the error was. Which is the main pain point I have.

I have already tried adding the --output flag but this only allows you to change the format of the output which is still not saved.


Solution

  • If you want to store complete log, the one that you see when your run that command without redirection then you can use &> instead of > for unix based systems.

    So it should look like

    aws s3 cp "logs.txt" s3://test/logs.txt --debug &> ./log_test.txt
    

    I am not 100% sure what is the Windows equivalent, but I think it is 2> so you can try

    aws s3 cp "logs.txt" s3://test/logs.txt --debug 2> ./log_test.txt