5

These are the docs for uwsgi logformat.

http://uwsgi-docs.readthedocs.io/en/latest/LogFormat.html

I have several unacceptable choices for outputting a timestamp in the log messages. Is there a way to format YYYY-MM-DD HH-MM-SS.DDDDDD that is just not documented?

boatcoder
  • 542

2 Answers2

7

Reading thru the code on github I found an issue that hinted at the solution.

Here is the command line I ended up using

uwsgi --log-date="%Y:%m:%d %H:%M:%S" --logformat-strftime --logformat="%(ftime) %(addr) (%(proto) %(status)) %(method) %(uri) : Retned %(size) bytes in %(msecs) msecs to %(uagent)" --http :9090 --wsgi-file foo.py 

There is virtually no way I could have come up with that by reading the docs. It does require all 3 options (not sure if the order matters) and the use of (%ftime) which is NOT mentioned on the logformat documentation page at all, only in the change log for one of the releases.

It does not appear possible to get the milliseconds in the log line

boatcoder
  • 542
0

Technically you can get the milliseconds with %(tmsecs) (since 1.9.21) in a raw format, but it's not really human readable and does not even separate the msec part with a dot: 1637061200823 (the last 3 digits).

I guess the easiest way for a python app is to use a "User-defined logvar", but i have no benchmarks about the overhead.

minusf
  • 161