download free 30 days trial version buy bucket explorer
Documentation  Download  Purchase  Support  FAQs   Forum   ScreenShots & Demos

How to Enable Logging on CloudFront Distribution (GET and PUT Distribution Config)?

You can work with Amazon CloudFront , a web service for content delivery, very easily using Bucket Explorer. CloudFront makes it easier to distribute content to end users quickly, with low latency and high data transfer speed. Amazon CloudFront delivers your content through a worldwide network of edge locations. Now Bucket Explorer has been enhanced with CloudFront logging feature. This feature will allow Amazon to log the operations performed on distributed contents. Logs are saved on the distributed bucket where you have set logging. CloudFront now supports Include Cookies for Download Distribution Logging. This will provide you with more information in the access logs.

You can set distribution logging by sending the PUT Request either using Amazon CloudFront API- PUT Distribution OR using Bucket Explorer User Interface. To use Amazon CloudFront API, you will need to write your own software program, however, if you do not want to write your program, you can use Bucket Explorer User Interface to set distribution logging using mouse clicks.

The below two sections describe how you can set distribution logging using the PUT Distribution request in your code or using Bucket Explorer.

1. Set Logging Using REST API

a. Download Distribution

To set logging while we are updating distribution, we perform PUT request with other distribution details -

PUT /2013-05-12/distribution/ distribution ID /config HTTP/1.1
Host: cloudfront.amazonaws.com
If-Match: value from ETag header in previous GET response
Authorization: AWS authentication string
Other required headers

<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2012-07-01/">
<Logging>
<Enabled>true</Enabled>
<IncludeCookies>true | false</IncludeCookies>
<Bucket> Amazon S3 bucket to save logs in </Bucket>
<Prefix> prefix for log filenames </Prefix>
</Logging>
. . . <REMAINING XML DETAILS>
</DistributionConfig>
 

b. Streaming Distribution

PUT Request to set logging while updating streaming distribution -

PUT /2013-05-12/streaming-distribution/ distribution Id /config HTTP/1.1
Host: cloudfront.amazonaws.com
If-Match: value from ETag header in previous GET response
Authorization: AWS authentication string
Other required headers

<?xml version="1.0" encoding="UTF-8"?>
<StreamingDistributionConfig>
<Logging>
<Enabled>true</Enabled>
<Bucket> Amazon S3 bucket for logs </Bucket>
<Prefix> prefix for log file names </Prefix>
</Logging>
. . . <REMAINING XML Doc>
</StreamingDistributionConfig>
 

2. Simple steps to set distribution logging using Bucket Explorer


Follow the steps below to Enable CloudFront Logging:
  1. Run Bucket Explorer.
  2. Click on  Distribution  button located in bucket toolbar.
  3. It will open a  List Distribution  window.
  4. Select row from the list of distributions.
  5. Click on  Set Logging .
  6. It will open Distribution Logging UI entitled “ Distribution Logging for the selected Bucket name”
  7. Write any  Prefix  whatever you want and Select bucket where you want to set logs.
  8. Now  you can add Include Cookies Option for Download Distribution (Does not support Streaming Distribution)
  9. Click  OK  and this will set CloudFront logging for the selected Bucket.