Content-Length: 260226 | pFad | https://github.com/scrapy/scrapy/issues/2802

24 Support ISO 8601 timestamps in logging · Issue #2802 · scrapy/scrapy · GitHub
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

Support ISO 8601 timestamps in logging #2802

Open
dalbani opened this issue Jun 22, 2017 · 7 comments · May be fixed by #2835
Open

Support ISO 8601 timestamps in logging #2802

dalbani opened this issue Jun 22, 2017 · 7 comments · May be fixed by #2835

Comments

@dalbani
Copy link

dalbani commented Jun 22, 2017

I haven't been able to configure logging via LOG_DATEFORMAT to output ISO 8601 timestamps.
Given that the logging formatter is passed local times apparently (??), I suppose that I need to use the %z qualifier.
But %z always returns +0000 in my configuration (Ubuntu 16.04, Linux 2.7) — whereas in my case %Z correctly produces CEST.
My understanding is that Python's logging.Formatter() doesn't support timezone offset: https://stackoverflow.com/questions/27858539/python-logging-module-emits-wrong-timezone-information##answer-27865750
Am I missing something obvious to be able to produce ISO 8601 timestamps in my Scrapy logs?

@dalbani
Copy link
Author

dalbani commented Jun 22, 2017

By the way, does this issue have someting to do with #2087?
And I also saw this pull request in the past in relation with the %z qualifier: #1278.

@redapple
Copy link
Contributor

@dalbani , I'm not really familiar with date formatting in loggers, but from what I see and tested locally, it would need a change in Scrapy's formatter setup to use formatter.converter = time.gmtime as @nramirezuy suggests here, so as to have UTC time objects, and then LOG_DATEFORMAT could be used to have Z or +0000.
This could mean introducing a new setting LOG_DATEFORMAT_UTC=True (defaulting to False probably).

@dalbani
Copy link
Author

dalbani commented Jul 18, 2017

@redapple: yes, that would be nice to have that kind of functionality.
For the record, the workaround I use in the meantime is to force the timezone with a TZ=UTC environment variable and with LOG_DATEFORMAT = '%Y-%m-%dT%H:%M:%SZ' where Z is hardcoded.

@redapple redapple linked a pull request Jul 18, 2017 that will close this issue
@redapple
Copy link
Contributor

@dalbani , would #2835 work for you?

@dalbani
Copy link
Author

dalbani commented Jul 19, 2017

@redapple: yes, that would be very useful to me 👍

@joshrg10

This comment was marked as resolved.

@Gallaecio

This comment was marked as resolved.

@wRAR wRAR added the logging label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/scrapy/scrapy/issues/2802

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy