Home > front end >  Is there a way to disable stdout logging for AWS java SDK 2.0. for S3 Bucket upload
Is there a way to disable stdout logging for AWS java SDK 2.0. for S3 Bucket upload

Time:07-28

Is there a way to disable the stdout responses when uploading to an s3 bucket? We currently log stdout, and as you can imagine this creates a lot of noise in our logs, and basically fills it up. Because of what we are using the S3 upload for it also creates an endless loop of uploading archived log files to the s3 bucket. We are using the AWS Java SDK 2.0. I am a little lost as to how this can be done, so any help will be appreciated. I see that it is logging out "http-outgoing-7 >>" as it uploads the file. enter image description here

Thanks

Here is a section of the code:

  private void setUpS3Client() {

S3Client s3Client = S3Client.builder()
    .credentialsProvider(createStaticCredentialsProvider())
    .region(Region.of(properties.get(IS3Constants.PROPERTY_REGION)))
    .build();

this.s3Client = s3Client;  
}

  private StaticCredentialsProvider createStaticCredentialsProvider() {
AwsBasicCredentials awsBasicCredentials = AwsBasicCredentials.create(properties.get(IS3Constants.PROPERTY_KEY_ID), properties.get(IS3Constants.PROPERTY_ACCESS_KEY));
StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(awsBasicCredentials);
return credentialsProvider; 

}

private void putS3Object(S3BucketRequest bucketRequest) throws IOException, GenericException {
    PutObjectRequest putObjectRequest = PutObjectRequest.builder()
    .bucket(bucketName)
    .key(fileName)
    .build();

byte[] objectByteArray = getObjectByteArray(bucketRequest.getFilePath());
if (objectByteArray == null || objectByteArray.length == 0) {
  Logger.logln(Logger.DEBUG, "Nothing to upload for "   bucketRequest.getFilePath());
}
PutObjectResponse putObjectResponse = s3Client.putObject(putObjectRequest, RequestBody.fromBytes(objectByteArray));
String eTag = putObjectResponse.eTag();
}

CodePudding user response:

I was able to solve this by reconfiguring "logback". I set the logs coming in from "org.apache.http" to 'WARN'. For me, by default, it was set to debug.

https://stackoverflow.com/a/51181745/5275728

  • Related