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
  • 1
  • 5
  • 20
  • Nice drive by downvote – boatcoder Oct 19 '17 at 19:33
  • Hi I'm also trying to figure out this log format, what is the six digit number after the timestamp? I'm trying to parse it for log aggregator and I can figure out YYYY-MM-DD:HH:MM:SS part, but not the `.DDDDDD` part. what is that, milliseconds? pid? – Noon Time Oct 04 '18 at 21:19
  • nevermind. DDDDDD are microseconds (right?) – Noon Time Oct 04 '18 at 21:37

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
  • 1
  • 5
  • 20
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
  • 1
  • 4