Forums

timezone of logs

Hi, I have updated by server timezone on my server and it is showing correctly as 'Europe/Belfast', but the access log (not sure about the error log) is still showing as utc meaning there is an hour of a difference, is there any way to update the timezone of the access & error logs? thanks

Are you using the technique on this help page? If so, then while the site is starting up (before it's run the code you put in the WSGI file) then unfortunately it will still use UTC, but after that it should switch to the requested timezone.

Hi, yes I followed the instructions on the help page. I added the line os.environ["TZ"] = "Europe/Belfast" to the bottom of the .bashhrc file and then at the top of my init.py I added the details advised on the help page:

from flask import Flask
from config import Config
from flask_mongoengine import MongoEngine
import os
import time

os.environ["TZ"] = "Europe/Belfast"
time.tzset()

app = Flask(__name__, instance_relative_config=True)

app.config['MONGODB_SETTINGS'] = {my connection settings in here}
db = MongoEngine(app)

if __name__ == '__main__':
    app.run()
app.config.from_object(Config)

from application import routes

Is that the correct place to add it? That was on Friday and the server has been restarted multiple times since then while doing other work, but the access log seems to still be on utc time, thanks.

Ah, sorry, I missed the fact that you were talking about the access log. Unfortunately that will always be in UTC -- it's handled by a different system that bypasses your code.