Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Portions copyright 2006-2009 James Murty. Please see LICENSE.txt
   * for applicable license terms and NOTICE.txt for applicable notices.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
  *
  *  http://aws.amazon.com/apache2.0
  *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.s3.model;
 

Represents bucket logging configuration used to control bucket-based server access logging in Amazon S3.

For logging to be enabled for a bucket both the destinationBucketName and logfilePrefix must not be null, and the named bucket must exist. When both variables are not null, this object represents an enabled logging configuration (as indicated by isLoggingEnabled()).

If either the targetBucketName or logfilePrefix are null, this object represents a disabled logging configuration (as indicated by isLoggingEnabled()).

Server access logging can be enabled or disabled with com.amazonaws.services.s3.AmazonS3Client.setBucketLoggingConfiguration(com.amazonaws.services.s3.model.SetBucketLoggingConfigurationRequest) and the current status of server access logging for a bucket can be retrieved through com.amazonaws.services.s3.AmazonS3Client.getBucketLoggingConfiguration(java.lang.String)

 
 public class BucketLoggingConfiguration {
     private String destinationBucketName = null;
     private String logFilePrefix = null;

    
Creates a new bucket logging configuration, which by default is disabled.

Passing this new object directly to com.amazonaws.services.s3.AmazonS3.setBucketLoggingConfiguration(com.amazonaws.services.s3.model.SetBucketLoggingConfigurationRequest) will turn off bucket logging for the specified bucket.

 
     public BucketLoggingConfiguration() {}

    
Creates a new bucket logging configuration which enables server access logs to be collected and stored in the specified destination bucket with the specified log file prefix.

Parameters:
destinationBucketName The name of the bucket to which to delivery server access logs from the target bucket. This may be the same bucket for which logging is being configured.
logFilePrefix The optional prefix to append to server access logs when they are written to the destination bucket.
 
     public BucketLoggingConfiguration(String destinationBucketNameString logFilePrefix) {
         setLogFilePrefix(logFilePrefix);
         setDestinationBucketName(destinationBucketName);
     }

    
Returns true if logging is enabled.

Returns:
True if logging is enabled.
 
     public boolean isLoggingEnabled() {
         return  != null
             &&  != null;
     }

    
Returns the optional log file prefix.

Returns:
The optional log file prefix.
 
     public String getLogFilePrefix() {
         return ;
     }

    
Sets the log file prefix for this bucket logging configuration.

Parameters:
logFilePrefix The log file prefix for this logging configuration.
    public void setLogFilePrefix(String logFilePrefix) {
        // Default log file prefix to the empty string if none is specified
        if (logFilePrefix == null)
            logFilePrefix = "";
        this. = logFilePrefix;
    }
    
    
Returns the destination bucket name for this logging configuration.

Returns:
The destination bucket name for this logging configuration.
    public String getDestinationBucketName() {
        return ;
    }

    
Sets the destination bucket name for this logging configuration.

Parameters:
destinationBucketName The destination bucket name for this logging configuration.
    public void setDestinationBucketName(String destinationBucketName) {
        this. = destinationBucketName;
    }
    public String toString() {
        String result = "LoggingConfiguration enabled=" + isLoggingEnabled();
        if (isLoggingEnabled()) {
            result += ", destinationBucketName=" + getDestinationBucketName()
                + ", logFilePrefix=" + getLogFilePrefix();
        }
        return result;
    }
New to GrepCode? Check out our FAQ X