Django: keep UTC time on registration when TIME_ZONE settings change
1 answer
Django uses Python loggers, so there shouldn't be anything Django-specific here.
According to the logging documentation, the setup logging.Formatter.converter = time.gmtime
should do all logs in UTC.
Alternatively, you can create your own class Formatter
to use UTC:
class UtcFormatter(logging.Formatter):
converter = time.gmtime
And then configure it using the key ()
(registered here ) in the dictconfig file:
LOGGING = {
'formatters': {
'utc': {
'()': 'my.package.UtcFormatter',
'format': '...',
'datefmt': '...',
}
}
}
+7
source to share