Stream Not Created / Logs not written DJango 2
See original GitHub issueI have the following configuration:
boto3_session = Session(aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
region_name=AWS_REGION_NAME)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'root': {
'level': LOG_LEVEL,
'handlers': ['console'],
},
'formatters': {
'simple': {
'format': u"%(asctime)s [%(levelname)-8s] %(message)s",
'datefmt': "%Y-%m-%d %H:%M:%S"
},
'aws': {
# you can add specific format for aws here
'format': u"%(asctime)s [%(levelname)-8s] %(message)s",
'datefmt': "%Y-%m-%d %H:%M:%S"
},
},
'handlers': {
'watchtower': {
'level': LOG_LEVEL,
'class': 'watchtower.CloudWatchLogHandler',
'boto3_session': boto3_session,
'log_group': 'MyLogGroup',
'create_log_group': False,
'stream_name': 'ops',
'formatter': 'aws',
},
'console': {
'class': 'logging.StreamHandler',
}
},
'loggers': {
'django': {
'level': LOG_LEVEL,
'handlers': ['watchtower'],
'propagate': False,
},
# add your other loggers here...
},
}
When I send my logs, I see that the “MyLogGroup” is created, but not the stream and therefore no logs either. When i turn on debugging for botocore, I see the following:
Loading variable region from instance vars with value 'us-west-2'.
Loading variable profile from defaults.
Loading variable ca_bundle from defaults.
Loading variable profile from defaults.
Loading variable api_versions from defaults.
Loading variable profile from defaults.
Event choose-service-name: calling handler <function handle_service_name_alias at 0x10ca50048>
Event creating-client-class.logs: calling handler <function add_generate_presigned_url at 0x10ca1a9d8>
The s3 config key is not a dictionary type, ignoring its value of: None
Setting logs timeout as (60, 60)
Registering retry handlers for service: logs
I confirm when I run the configuration through this set of commands everything works as expected: import watchtower, logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(name) logger.addHandler(watchtower.CloudWatchLogHandler()) logger.info(“Hi”)
So it seems to me that the handler is not being registered correctly
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Log messages from Django application not uploaded in AWS ...
When I run the application it creates log group in AWS CloudWatch but log stream is not created and log messages also not...
Read more >Logging - Django documentation
A logger is the entry point into the logging system. Each logger is a named bucket to which messages can be written for...
Read more >Install and configure the CloudWatch Logs agent on a running ...
Step 1: Configure your IAM role or user for CloudWatch Logs · In the navigation pane, choose Roles. · Choose the role by...
Read more >Python Logging Guide - Best Practices and Hands-on Examples
Line 2: create a basicConf function and pass some arguments to create ... 0 and not equal to pre-defined logging levels as logging...
Read more >How to Collect, Customize, and Centralize Python Logs
Python's built -in logging module is designed to give you critical ... In the example above, an error message was logged, but it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve resolved this issue by setting
use_queues: False
forwatchtower
handler like below:Hope this setting also resolves your problem.
@terencehonles thanks, this is a good point; I should probably just go ahead and use per-thread boto3 clients unless a custom one was passed in at init time.