:doc:`BucketLogging <index>` / Action / put

***
put
***



.. py:method:: S3.BucketLogging.put(**kwargs)

  

  .. warning::

    

    End of support notice: As of October 1, 2025, Amazon S3 has discontinued support for Email Grantee Access Control Lists (ACLs). If you attempt to use an Email Grantee ACL in a request after October 1, 2025, the request will receive an ``HTTP 405`` (Method Not Allowed) error.

     

    This change affects the following Amazon Web Services Regions: US East (N. Virginia), US West (N. California), US West (Oregon), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland), and South America (São Paulo).

     

   

  .. note::

    

    This operation is not supported for directory buckets.

    

   

  Set the logging parameters for a bucket and to specify permissions for who can view and modify the logging parameters. All logs are saved to buckets in the same Amazon Web Services Region as the source bucket. To set the logging status of a bucket, you must be the bucket owner.

   

  The bucket owner is automatically granted FULL_CONTROL to all logs. You use the ``Grantee`` request element to grant access to other people. The ``Permissions`` request element specifies the kind of access the grantee has to the logs.

   

  .. warning::

     

    If the target bucket for log delivery uses the bucket owner enforced setting for S3 Object Ownership, you can't use the ``Grantee`` request element to grant access to others. Permissions can only be granted using policies. For more information, see `Permissions for server access log delivery <https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-server-access-logging.html#grant-log-delivery-permissions-general>`__ in the *Amazon S3 User Guide*.

     

    Grantee Values  

  You can specify the person (grantee) to whom you're assigning access rights (by using request elements) in the following ways. For examples of how to specify these grantee values in JSON format, see the Amazon Web Services CLI example in `Enabling Amazon S3 server access logging <https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-server-access-logging.html>`__ in the *Amazon S3 User Guide*.

   

  
  * By the person's ID: ``<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID><>ID<></ID><DisplayName><>GranteesEmail<></DisplayName> </Grantee>`` ``DisplayName`` is optional and ignored in the request.
   
  * By Email address: ``<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail"><EmailAddress><>Grantees@email.com<></EmailAddress></Grantee>`` The grantee is resolved to the ``CanonicalUser`` and, in a response to a ``GETObjectAcl`` request, appears as the CanonicalUser.
   
  * By URI: ``<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group"><URI><>http://acs.amazonaws.com/groups/global/AuthenticatedUsers<></URI></Grantee>``
  

     

  To enable logging, you use ``LoggingEnabled`` and its children request elements. To disable logging, you use an empty ``BucketLoggingStatus`` request element:

   

  ``<BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/2006-03-01" />``

   

  For more information about server access logging, see `Server Access Logging <https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html>`__ in the *Amazon S3 User Guide*.

   

  For more information about creating a bucket, see `CreateBucket <https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html>`__. For more information about returning the logging status of a bucket, see `GetBucketLogging <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLogging.html>`__.

   

  The following operations are related to ``PutBucketLogging``:

   

  
  * `PutObject <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html>`__
   
  * `DeleteBucket <https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html>`__
   
  * `CreateBucket <https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html>`__
   
  * `GetBucketLogging <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLogging.html>`__
  

   

  .. warning::

     

    You must URL encode any signed header values that contain spaces. For example, if your header value is ``my file.txt``, containing two spaces after ``my``, you must URL encode this value to ``my%20%20file.txt``.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutBucketLogging>`_  


  **Request Syntax**
  ::

    response = bucket_logging.put(
        BucketLoggingStatus={
            'LoggingEnabled': {
                'TargetBucket': 'string',
                'TargetGrants': [
                    {
                        'Grantee': {
                            'DisplayName': 'string',
                            'EmailAddress': 'string',
                            'ID': 'string',
                            'Type': 'CanonicalUser'|'AmazonCustomerByEmail'|'Group',
                            'URI': 'string'
                        },
                        'Permission': 'FULL_CONTROL'|'READ'|'WRITE'
                    },
                ],
                'TargetPrefix': 'string',
                'TargetObjectKeyFormat': {
                    'SimplePrefix': {}
                    ,
                    'PartitionedPrefix': {
                        'PartitionDateSource': 'EventTime'|'DeliveryTime'
                    }
                }
            }
        },
        ChecksumAlgorithm='CRC32'|'CRC32C'|'SHA1'|'SHA256'|'CRC64NVME',
        ExpectedBucketOwner='string'
    )
    
  :type BucketLoggingStatus: dict
  :param BucketLoggingStatus: **[REQUIRED]** 

    Container for logging status information.

    

  
    - **LoggingEnabled** *(dict) --* 

      Describes where logs are stored and the prefix that Amazon S3 assigns to all log object keys for a bucket. For more information, see `PUT Bucket logging <https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTlogging.html>`__ in the *Amazon S3 API Reference*.

      

    
      - **TargetBucket** *(string) --* **[REQUIRED]** 

        Specifies the bucket where you want Amazon S3 to store server access logs. You can have your logs delivered to any bucket that you own, including the same bucket that is being logged. You can also configure multiple buckets to deliver their logs to the same target bucket. In this case, you should choose a different ``TargetPrefix`` for each source bucket so that the delivered log files can be distinguished by key.

        

      
      - **TargetGrants** *(list) --* 

        Container for granting information.

         

        Buckets that use the bucket owner enforced setting for Object Ownership don't support target grants. For more information, see `Permissions for server access log delivery <https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-server-access-logging.html#grant-log-delivery-permissions-general>`__ in the *Amazon S3 User Guide*.

        

      
        - *(dict) --* 

          Container for granting information.

           

          Buckets that use the bucket owner enforced setting for Object Ownership don't support target grants. For more information, see `Permissions server access log delivery <https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-server-access-logging.html#grant-log-delivery-permissions-general>`__ in the *Amazon S3 User Guide*.

          

        
          - **Grantee** *(dict) --* 

            Container for the person being granted permissions.

            

          
            - **DisplayName** *(string) --* 

            
            - **EmailAddress** *(string) --* 

            
            - **ID** *(string) --* 

              The canonical user ID of the grantee.

              

            
            - **Type** *(string) --* **[REQUIRED]** 

              Type of grantee

              

            
            - **URI** *(string) --* 

              URI of the grantee group.

              

            
          
          - **Permission** *(string) --* 

            Logging permissions assigned to the grantee for the bucket.

            

          
        
    
      - **TargetPrefix** *(string) --* **[REQUIRED]** 

        A prefix for all log object keys. If you store log files from multiple Amazon S3 buckets in a single bucket, you can use a prefix to distinguish which log files came from which bucket.

        

      
      - **TargetObjectKeyFormat** *(dict) --* 

        Amazon S3 key format for log objects.

        

      
        - **SimplePrefix** *(dict) --* 

          To use the simple format for S3 keys for log objects. To specify SimplePrefix format, set SimplePrefix to {}.

          

        
        
        - **PartitionedPrefix** *(dict) --* 

          Partitioned S3 key for log objects.

          

        
          - **PartitionDateSource** *(string) --* 

            Specifies the partition date source for the partitioned prefix. ``PartitionDateSource`` can be ``EventTime`` or ``DeliveryTime``.

             

            For ``DeliveryTime``, the time in the log file names corresponds to the delivery time for the log files.

             

            For ``EventTime``, The logs delivered are for a specific day only. The year, month, and day correspond to the day on which the event occurred, and the hour, minutes and seconds are set to 00 in the key.

            

          
        
      
    
  
  :type ChecksumAlgorithm: string
  :param ChecksumAlgorithm: 

    Indicates the algorithm used to create the checksum for the request when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding ``x-amz-checksum`` or ``x-amz-trailer`` header sent. Otherwise, Amazon S3 fails the request with the HTTP status code ``400 Bad Request``. For more information, see `Checking object integrity <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html>`__ in the *Amazon S3 User Guide*.

     

    If you provide an individual checksum, Amazon S3 ignores any provided ``ChecksumAlgorithm`` parameter.

    

  
  :type ExpectedBucketOwner: string
  :param ExpectedBucketOwner: 

    The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code ``403 Forbidden`` (access denied).

    

  
  
  :returns: None