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

web access log show utc time instead local time with timezone. #3853

Closed
NewUserHa opened this issue Jun 18, 2019 · 11 comments · Fixed by #3860
Closed

web access log show utc time instead local time with timezone. #3853

NewUserHa opened this issue Jun 18, 2019 · 11 comments · Fixed by #3860

Comments

@NewUserHa
Copy link
Contributor

Long story short

in web_.log.py:

    def _format_t(request: BaseRequest,
                  response: StreamResponse,
                  time: float) -> str:
        now = datetime.datetime.utcnow()
        start_time = now - datetime.timedelta(seconds=time)
        return start_time.strftime('[%d/%b/%Y:%H:%M:%S +0000]')

the logged time is fixed and is a utc time, not a local time. there's not a easy way to setting it.

Expected behaviour

INFO:aiohttp.access:127.0.0.1 [18/Jun/2019:04:56:22 -8]

Actual behaviour

INFO:aiohttp.access:127.0.0.1 [18/Jun/2019:04:56:22 +0000]
@asvetlov
Copy link
Member

UTC time is intentional.

@webknjaz
Copy link
Member

It's nice to make it customizable. I see it being useful during the development in particular.

@NewUserHa feel free to research improving this and send a PR.

@NewUserHa
Copy link
Contributor Author

NewUserHa commented Jun 19, 2019

nginx's access.log is [16/Jun/2019:15:25:04 +0800]

what about making _format_t to obey OS or python's timezone info? I doubt adding a parameter for customing will work.

@asvetlov
Copy link
Member

What is apache behavior?

@NewUserHa
Copy link
Contributor Author

127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 from https://httpd.apache.org/docs/2.4/logs.html

@asvetlov
Copy link
Member

Ok, I have no objections for changing defaults to use local time instead of UTC. The output should include a timezone offset like @NewUserHa mentioned: [16/Jun/2019:15:25:04 +0800]

@NewUserHa
Copy link
Contributor Author

I would like to PR this too. (though the other one still is not finished)...

what about obeying OS or python's timezone info? need import like pytz module for ease?

@asvetlov
Copy link
Member

Don't follow what is the difference between OS and python TZ info?
Please no pytz if we can avoid the library (I think we cannot need if for local timezone-aware time).

@NewUserHa
Copy link
Contributor Author

NewUserHa commented Jun 19, 2019

hmm.. maybe someone has different values for OS and python TZ info.
ok.

@NewUserHa
Copy link
Contributor Author

#3860

@helpr helpr bot added the pr-merged label Jun 22, 2019
@webknjaz
Copy link
Member

Resolved by #3860.

@lock lock bot added the outdated label Jun 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants