diff --git a/cdsapi/api.py b/cdsapi/api.py index a603716..550c18e 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -278,9 +278,14 @@ def __init__( else: level = logging.INFO - logging.basicConfig( - level=level, format="%(asctime)s %(levelname)s %(message)s" - ) + self.logger.setLevel(level) + + # avoid duplicate handlers when creating more than one Client + if not self.logger.handlers: + formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") + handler = logging.StreamHandler() + handler.setFormatter(formatter) + self.logger.addHandler(handler) dotrc = os.environ.get("CDSAPI_RC", os.path.expanduser("~/.cdsapirc"))