Search code examples
spring-bootlog4jslf4j

Turn off AWS logging on SpringBoot


I have an annoying error looping during the service run, this only happens on local and it's right because this functionality is not supposed to work on local.

I want to turn off that logging but even I tried several things, is still happening.

This is the trace:

    [ntContainer#0-4] [:] c.a.s.j.AmazonSQSMessagingClientWrapper  : AmazonClientException: getQueueUrl.
com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: You must specify a value for roleArn and roleSessionName, com.amazonaws.auth.profile.ProfileCredentialsProvider@5a472e9d: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@61eee6c7: The requested metadata is not found at http://someip/latest/meta-data/iam/security-credentials/]
                at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:136) ~[aws-java-sdk-core-1.12.262.jar:na]
                at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1269) ~[aws-java-sdk-core-1.12.262.jar:na]
                at com.amazonaws.http.AmazonHttpClient$RequestExecutor.runBeforeRequestHandlers(AmazonHttpClient.java:845) ~[aws-java-sdk-core-1.12.262.jar:na]
                at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:794) ~[aws-java-sdk-core-1.12.262.jar:na]
                at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:781) ~[aws-java-sdk-core-1.12.262.jar:na]

What I tried is to add to the apllication properties these 2 props:

logging.level.com.amazonaws=OFF logging.level.c.a.s.j=OFF

Plus editing the logging.properties JDK file adding the line: com.amazonaws.level = OFF

But nothing of this works. Any idea?


Solution

  • c.a.s.j is not the package name but just a shortened version (shortened by your default logger formatting) -> you need to use logging.level.com.amazon.sqs.javamessaging=OFF