watchtower icon indicating copy to clipboard operation
watchtower copied to clipboard

Django Logging not create log group, type error.

Open Plaoo opened this issue 3 years ago • 0 comments

Hi in my Django project I have implemented the log on Cloudwatch, but the parameter `` log_group_name``` gives me an error,

Invalid type for parameter logGroupNamePrefix, value: ('mylogname',), type: <class 'logging.config.ConvertingTuple'>, valid types: <class 'str'>

When in reality it is a string.

boto3_connect_session = boto3.client("logs", region_name=AWS_REGION_NAME)
AWS_LOG_GROUP = 'mylogname'
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'aws': {
            'format': u"%(asctime)s [%(levelname)-8s] %(message)s [%(pathname)s:%(lineno)d]",
            'datefmt': "%Y-%m-%d %H:%M:%S"
        },
        'simple': {
            'format': '[%(asctime)s %(module)s] %(levelname)s: %(message)s'
        },
    },
    'handlers': {
        AWS_LOGGER_NAME: {
           'level': 'DEBUG',
           'class': 'watchtower.CloudWatchLogHandler',
           'boto3_client': boto3_connect_session,
           'log_group_name': AWS_LOG_GROUP,
           'formatter': 'aws',
       },
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'simple',
        },
    },
    'loggers': {
        AWS_LOGGER_NAME: {
            'level': 'DEBUG',
            'handlers': [AWS_LOGGER_NAME],
            'propagate': False,
        },
        'django': {
            'handlers': ['console'],
            'level': 'INFO',
            'propagate': True,
        },
        '': {
            'handlers': ['console'],
            'level': 'INFO',
            'propagate': True,
        },
    },
}

Can you tell me how to solve it, obviously I don't want the logs to read watchtower

Plaoo avatar Feb 03 '22 13:02 Plaoo