2

I'm using AWS JavaScript SDK in nodejs application. SDK setup is as below.

const aws = require('aws-sdk');
aws.config.logger = console;

This config is creating too much noise on console and it's difficult to go over the log. I tried removing aws.config.logger = console; but that doesn't change anything, still every log is being printed on console.

6
  • The logger is off by default. You should not be seeing any AWS SDK logs unless you explicitly set aws.config.logger. Are you sure that you saw logs after you commented out that assignment?
    – jarmod
    Jun 24, 2021 at 13:52
  • @jarmod yes i'm very sure those were from AWS SDK. Jun 25, 2021 at 14:37
  • I suspect you were not running the changed code. The AWS JavaScript SDK does not emit logs by default, to the best of my knowledge. So, the accepted answer is not actually necessary at all afaik.
    – jarmod
    Jun 25, 2021 at 14:38
  • @jarmod I'm running the updated code, however, this is not the only client I have, there are other aws clients too. but I want to disable the logs specifically for this client as I don't need them. Is it possible that the config defined for other aws client is affecting this one? Jun 28, 2021 at 6:28
  • 1
    The config object is global for an application, it's not per SDK client. So if you have multiple client objects in the same app, they'll share the global config.
    – jarmod
    Jun 28, 2021 at 13:14

1 Answer 1

1

You can try by disable the Main Console to print anything in the log bar. Put the below code in your main file through which your server get starts. Here is the code snippet:

console.log = function(){};

or

console = function(){};

Your complete code may look like:

const aws = require('aws-sdk');
aws.config.logger = console;
console.log = function(){};
1
  • Won't this disable ALL console logging throughout the app? Jan 20 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.