Logging can't format stack trace with non-ascii chars on Python 2
See original GitHub issueHi,
I experience the same issue as described in #1602. However, I’m not using Django.
The stats look like this:
{'downloader/request_bytes': 47621,
'downloader/request_count': 103,
'downloader/request_method_count/GET': 103,
'downloader/response_bytes': 1162618,
'downloader/response_count': 103,
'downloader/response_status_count/200': 101,
'downloader/response_status_count/302': 2,
'dupefilter/filtered': 2,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2018, 3, 9, 2, 3, 15, 748633),
'httpcache/firsthand': 72,
'httpcache/hit': 31,
'httpcache/miss': 72,
'httpcache/store': 72,
'item_scraped_count': 48,
'log_count/DEBUG': 215,
'log_count/ERROR': 1,
'log_count/INFO': 9,
'memusage/max': 121434112,
'memusage/startup': 69783552,
'mongodb/item_stored_count': 48,
'request_depth_max': 3,
'response_received_count': 101,
'scheduler/dequeued': 102,
'scheduler/dequeued/memory': 102,
'scheduler/enqueued': 102,
'scheduler/enqueued/memory': 102,
'spider_exceptions/AttributeError': 1,
'start_time': datetime.datetime(2018, 3, 9, 2, 0, 52, 510449)}
But there’s no mention about AttributeError
(or any other error) in the log.
I’m executing the spiders on Scrapyd instances running in Docker container. This is the first two lines of the log showing components’ versions:
2018-03-09 02:00:52 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: realestate)
2018-03-09 02:00:52 [scrapy.utils.log] INFO: Versions: lxml 4.1.1.0, libxml2 2.9.7, cssselect 1.0.3, parsel 1.3.1, w3lib 1.18.0, Twisted 17.9.0, Python 2.7.12 (default, Nov 20 2017, 18:23:56) - [GCC 5.4.0 20160609], pyOpenSSL 17.5.0 (OpenSSL 1.1.0g 2 Nov 2017), cryptography 2.1.4, Platform Linux-4.4.0-103-generic-x86_64-with-Ubuntu-16.04-xenial
There’s nothing special in the settings.py
, but I can provide it if needed.
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (9 by maintainers)
Top Results From Across the Web
properly logging unicode & utf-8 exceptions in python 2
The logging.exception(msg) call seems to properly use the repr() for formatting the exception for logging and prefixes it with your msg .
Read more >Logging HOWTO — Python 3.11.1 documentation
Logging is a means of tracking events that happen when some software runs. The software's developer adds logging calls to their code to...
Read more >Overcoming frustration: Correctly using unicode in python2
Python will try to implicitly convert from unicode to byte str... but it will throw an exception if the bytes are non-ASCII:.
Read more >1541963 – Error when deploying overcloud - Red Hat Bugzilla
Description of problem: While deploying overcloud i had an issue UnicodeEncodeError: [stack@director ~]$ ./deploy.sh Removing the current plan files ...
Read more >Resolving Issue with Logging Formatter & Unicode in Python 2.7
In Python 2.7 on Windows, I was using a RotatingFileHandler with a ... the logging, I was getting an error with the following...
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
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
Thanks for sharing the code that causes the issue @tlinhart
I managed to reproduce it with the following minimal spider:
@ayushmankoul if you want to help, above is a starting point. thanks
Hey, @cathalgarvey @kmike I am interested in solving this bug.Please help me to fix this bug.Any guidance would be surely helpful to me.Thank You