Skip to content

Log Management

David Alonso (Solvos) edited this page Sep 18, 2025 · 2 revisions

Log Management

We can make a more efficient saving way of logs, access control and internal rotation. For that we need to add (in the future, this step will be no necessary, as this will be added)

First enter on docker_compose.yaml

nano docker_compose.yaml

After env_file add the next lines

logging:
  driver: local
  options:
    max-size: "10m"
    max-file: "10"

Restart Odoo

sudo docker-compose down
sudo docker-compose up -d

This changes from default driver json-file to local which is better, as it write logs on internal storage that have better performance.

⚠️ It only changes to the container of the instance you create. Default driver still json-file. You can check with next commands:

sudo docker inspect -f '{{.HostConfig.LogConfig.Type}}' $container_name  #Check it uses local driver.
sudo docker info --format '{{.LoggingDriver}}'  #Check that `json-file` still global driver for other containers.

Docker Logs: View and Stream Logs from Containers

You can use the docker logs command to retrieve and manage container logs. This command reads the STDOUT and STDERR streams of a running or stopped container.

Basic usage

sudo docker logs $container_name_or_id

This shows all available logs from the container up to the moment the command is run.

Options

Option Description
--details Show extra log details such as labels or environment variables if configured
-f, --follow Follow the log output in real-time
--since Show logs since a given timestamp or duration (e.g. 2025-04-15T08:00:00Z or 30m)
--until Show logs up until a specific timestamp or duration
-n, --tail Show the last N lines of logs (default is all)
-t, --timestamps Include timestamps for each log line in RFC3339Nano format

Examples

  • Show all logs from a container
sudo docker logs $container_name_or_id
  • Show logs in real-time (like tail -f)
sudo docker logs -f $container_name_or_id
  • Show the last 100 log lines
sudo docker logs --tail 100 $container_name_or_id
  • Include timestamps in log output
sudo docker logs --timestamps $container_name_or_id

Example output:

2025-04-15T10:24:30.000000000Z Starting server...
2025-04-15T10:24:35.000000000Z Connection established
  • Show logs from the last 30 minutes
sudo docker logs --since 30m $container_name_or_id
  • Show logs between 1 hour ago and 15 minutes ago
sudo docker logs --since 1h --until 15m $container_name_or_id
  • Show logs from a specific timestamp
sudo docker logs --since "2025-04-15T08:00:00Z" $container_name_or_id
  • Show logs with extra details
sudo docker logs --details $container_name_or_id

⚠️ This only works if the container was started with advanced logging options (--log-opt).

Notes

If you pass a negative number or a non-integer to --tail, it will default to showing all logs. Supported time formats for --since and --until:

RFC3339 or RFC3339Nano (e.g., 2025-04-15T08:00:00Z)
Relative durations (e.g., 45m, 2h, 1d)
Local timestamps (e.g., 2025-04-15T08:00:00) will use your machine's time zone

You can combine --since, --until, --tail, and --follow to fine-tune your log inspection.

Docker Logs - Compose Mode

docker-compose has its own logs command option, that has the same options than standard docker command. The main differences are the following:

  • Commands need to be run within the folder that contains docker-compose.xml file.
  • Instead of calling with container name or id, service name, as defined in docker-compose.yml could be used (or nothing, if both services logs can be displayed). These services names are always odoo and db.
  • It doesn't support standard docker logs command options, such since and until.

Command examples

sudo docker-compose logs -f odoo                                 # Shows Odoo live logs
sudo docker-compose logs --tail 100 odoo                         # Shows Odoo log last 100 lines

Clone this wiki locally