Skip to content

Logging

Kevin Weng edited this page Apr 12, 2020 · 1 revision

Currently, logs are handled by the Docker system. Docker will automatically log console outputs from both the Node and Python servers.

  • In the Node server, things are logged simply using console.log
  • In the Python server, it uses the logging module which provides different levels of logging like INFO and DEBUG - however everything is automatically stored by Docker

You can customize the log options for each Docker container in the YAML config files (e.g. docker-compose.yml). For example, the logging options for server is

server:
  logging:
    driver: "json-file"
    options:
      max-size: "20m"
      max-file: "5"

driver refers to the type of logs that Docker will store and this value should not be changed from json-file. max-size refers the max size a single log file can get and max-file refers to the maximum number of log files Docker will. Note that if you do not specify a max-file while specifying max-size, the default value of max-file becomes 1.

Docker logs (for the server) are stored at /var/lib/docker/containers with extension *json.log. Note that each service or Docker container (like web and server) are associated with a container ID and the logs are stored under a directory with the name as the container ID.

To view your containers and their IDs (the IDs are truncated), use

docker ps -a

For example, if the server service's container ID starts with 2df34de1716e, its logs will be in

/var/lib/docker/containers/2df34de1716e.../2df34de1716e...-json.log

If you want to manually access these logs, you might have to elevate your permissions, which you can do by running sudo -i in the terminal and to exit, simply type exit.

Clone this wiki locally