Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker, Supervisord and logging - how to consolidate logs in docker logs?

So, experimenting with Docker + Supervisord + Django app via uWSGI. I have the whole stack working fine, but need to tidy up the logging.

If I launch supervisor in non-daemon mode,

/usr/bin/supervisord -n 

Then I get the logging output for supervisor played into the docker logs stdout. However, if supervisord is in daemon mode, its own logs get stashed away in the container filesystem, and the logs of its applications do too - in their own app__stderr/stdout files.

What I want is to log both supervisor, and application stdout to the docker log.

Is starting supervisord in non-daemon mode a sensible idea for this, or does it cause unintended consequences? Also, how do I get the application logs also played into the docker logs?

like image 951
jvc26 Avatar asked Sep 08 '13 12:09

jvc26


People also ask

How do I get full docker logs?

First of all, to list all running containers, use the docker ps command. Then, with the docker logs command you can list the logs for a particular container. Most of the time you'll end up tailing these logs in real time, or checking the last few logs lines.

What is Supervisord in docker?

Your Ubuntu 18.04 docker image will require a one-time configuration of Supervisord to get started with process monitoring. Supervisord — A Process Control System, which will run and manage your command-based programs from a simple configuration file setup.


1 Answers

I accomplished this using .

Install supervisor-stdout in your Docker image:

RUN apt-get install -y python-pip && pip install supervisor-stdout 

Supervisord Configuration

Edit your supervisord.conf look like so:

[program:myprogram] command=/what/ever/command stdout_events_enabled=true stderr_events_enabled=true  [eventlistener:stdout]  command = supervisor_stdout  buffer_size = 100  events = PROCESS_LOG  result_handler = supervisor_stdout:event_handler 
like image 99
Drew Avatar answered Sep 22 '22 12:09

Drew