Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to set logging in Django -- TypeError: __init__() got an unexpected keyword argument 'boto3_client' #161

Closed
kaushikbhanu opened this issue Nov 15, 2021 · 1 comment

Comments

@kaushikbhanu
Copy link

kaushikbhanu commented Nov 15, 2021

I am trying to setup the logging in my Django app. and some how its throwing me the
TypeError: init() got an unexpected keyword argument 'boto3_client'

Unable to figure out what am I missing here.

import boto3
boto3_logs_client = boto3.client("logs", region_name=AWS_REGION)

LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"aws": {
"format": "%(asctime)s [%(levelname)-8s] %(message)s [%(pathname)s:%(lineno)d]",
"datefmt": "%Y-%m-%d %H:%M:%S",
},
},
"handlers": {
"watchtower": {
"level": "INFO",
'class': 'watchtower.CloudWatchLogHandler',
"boto3_client": boto3_logs_client,
"log_group": "my-app-logs",
"stream_name": f"app-logs",
"formatter": "aws",
},
"console": {
"class": "logging.StreamHandler",
"formatter": "aws",
},
},
"loggers": {
"watchtower": {
"level": "INFO",
"handlers": ["watchtower"],
"propogate": False,
}
},
}

full error:

Exception in thread django-main-thread:
Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 563, in configure
handler = self.configure_handler(handlers[name])
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 744, in configure_handler
result = factory(**kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/watchtower/init.py", line 129, in init
super().init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'boto3_client'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/miniconda3/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/init.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/init.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 808, in dictConfig
dictConfigClass(config).configure()
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 570, in configure
raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'watchtower'
/Users/bkaushik/Desktop/devel/qurx/api/REST/settings/local.py changed, reloading.
/Users/bkaushik/Desktop/devel/qurx/api/REST/../api/templates
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 563, in configure
handler = self.configure_handler(handlers[name])
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 744, in configure_handler
result = factory(**kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/watchtower/init.py", line 129, in init
super().init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'boto3_client'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/miniconda3/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/init.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/init.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 808, in dictConfig
dictConfigClass(config).configure()
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 570, in configure
raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'watchtower'
/Users/bkaushik/Desktop/devel/qurx/api/REST/settings/local.py changed, reloading.
/Users/bkaushik/Desktop/devel/qurx/api/REST/../api/templates
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 563, in configure
handler = self.configure_handler(handlers[name])
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 744, in configure_handler
result = factory(**kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/watchtower/init.py", line 129, in init
super().init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'boto3_client'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/miniconda3/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/init.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/init.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 808, in dictConfig
dictConfigClass(config).configure()
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 570, in configure
raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'watchtower'
/Users/bkaushik/Desktop/devel/qurx/api/REST/settings/local.py changed, reloading.
/Users/bkaushik/Desktop/devel/qurx/api/REST/../api/templates
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 563, in configure
handler = self.configure_handler(handlers[name])
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 744, in configure_handler
result = factory(**kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/watchtower/init.py", line 129, in init
super().init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'boto3_client'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/miniconda3/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/core/management/init.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/init.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/bkaushik/Desktop/devel/qurx/venv-develop/lib/python3.8/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 808, in dictConfig
dictConfigClass(config).configure()
File "/opt/miniconda3/lib/python3.8/logging/config.py", line 570, in configure
raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'watchtower'

@kaushikbhanu
Copy link
Author

seems like my bad. the versions in my local and ec2box were different. making them consistent to 2.0.0 worked . Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant