Skip to content

Instantly share code, notes, and snippets.

@barend
Created October 26, 2020 09:44
Show Gist options
  • Save barend/7b09dfc95c68083402964ff11c54c347 to your computer and use it in GitHub Desktop.
Save barend/7b09dfc95c68083402964ff11c54c347 to your computer and use it in GitHub Desktop.
Configure Python logging with ISO-8601 format and UTC time
import logging
from time import gmtime
# https://stackoverflow.com/a/7517430/49489
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s.%(msecs)03dZ [%(name)s] %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S",
)
logging.Formatter.converter = gmtime
@Arnold1
Copy link

Arnold1 commented Feb 26, 2023

what to change if you need EST time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment