AWS Code Sample
Catalog

logging.java

logging.java demonstrates how to ...

package com.example.general; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.services.s3.model.ListBucketsRequest; import software.amazon.awssdk.services.s3.model.ListBucketsResponse; public class logging { private static final Logger logger = LogManager.getLogger(logging.class); public static void main (String[] args) { System.out.println("testing logging setup for " + logging.class); S3Client s3 = S3Client.builder().build(); ListBucketsRequest listBucketsRequest = ListBucketsRequest.builder().build(); ListBucketsResponse listBucketsResponse = s3.listBuckets(listBucketsRequest); listBucketsResponse.buckets().stream().forEach(x -> System.out.println(x.name())); logger.info("logging level info"); logger.debug("logging debug stuff"); logger.warn("logging warning"); logger.error("logging error"); logger.fatal("logging fatal"); } }

Sample Details

Service: s3

Author: soo-aws

Type: full-example

On this page: