8

I'm deploying via Kuberenetes come containers on Google Cloud, which are django project and uwsgi to run them.

I'm using the stackdrive logging tool to see the logging, the problem is that all the entries are seen as severity ERROR even thought they are not error. It seems that the log of uwsgi is written to stderr or something like that.

In the picture you can see that django uses INFO level, but that is received as ERROR by stackdrive.

enter image description here

this is how i set up uwsgi.

[uwsgi] master = true socket = :3031 chdir = . wsgi-file = docker.wsgi processes = 4 threads = 2 socket-timeout = 90 harakiri = 90 http = :8000 env = prometheus_multiproc_dir=multi enable-threads = yes lazy-apps = yes pidfile=/tmp/project-master.pid

EsseTi
  • 4,079
  • 5
  • 36
  • 63

2 Answers2

4

Kubernetes logs written to stderr are always tagged as ERROR -- this is hard-coded in the Stackdriver logging agent. Similarly, logs written to stdout are always tagged with INFO.

If you can configure your application to write non-error log messages to stdout, please do so. Another possible approach is to write the logs to a file, run the "tail -f" command on that file as a sidecar container in the same pod, and looking for your logs in Stackdriver Logs Viewer under the sidecar container instead. Finally, you might consider writing your logs directly into the Stackdriver Logging API, which gives you full control over the contents of each entry.

Igor Peshansky
  • 727
  • 4
  • 12
  • Oh wow, thanks for this. I've been scratching my head as to why these logs all look like 'errors'. – Sam Kenny Jun 30 '17 at 21:43
  • 1
    To add to my answer, if you are able to write logs to stdout/stderr in JSON format, the logging agent will parse them into structured payloads, and the "severity" field in the payload will override the hard-coded severity. – Igor Peshansky Jul 05 '17 at 21:34
3

This answer helped me find the solution to this. Using the option logger-req=stdio uWSGI logs get the correct level in Stackdriver.

Example of uwsgi.ini:

[uwsgi]
logger-req=stdio
Parham
  • 3,157
  • 4
  • 31
  • 44