Traefik logs -- how best to manage

So I've used this post as a reference:

My docker logs traefik file is getting very long. Per the post above the it would appear the defulat to to log to stdout, but it seems with docker the default log driver is json, and this file is kept within:

I'm really just trying to rotate the logs using logrotate to keep the traefik log as concise as possible. I've found a post on stack overflow discussing how to setup a setup with logrotate: How to enable logrotation for traefik? - Stack Overflow

The only problem with these instructions is that my traefik logs are not within:

If a define an access log path similar to:

    image: traefik:latest
    restart: unless-stopped
      - "--log.level=DEBUG"
      - "--accesslog=/var/log/access.log"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "/var/log/traefik:/var/log"

Will this capture the docker logs so I can appropriately rotate them or will the default logging location still be used (/var/lib/docker/containers/<container_id>/<container_id>-json.log)?

Just curious how best to implement this.

1 Like

Hi @kevdog

Docker natively supports rotating the log using the docker default log driver json-file.

You can set it per container or for the docker daemon as a whole.

Or you can choose a different log-driver altogether. You could, for example, us the syslog log-driver to send to your local syslog and then use regular log-rotate rules.

Alternatively you mount a directory and as per the referenced post use --accesslog.filepath. Log rotation(logrotate) would need issue a USR1 signal to complete rotation in an orderly fashion.

Hope this helps.

Thanks for the reference. I wasn't aware. Definitely pretty easy to configure json logging options with that link.

1 Like

I am not using docker. How log rotation can be set for windows?

This question is specifically asked with a docker tag. Your is related but off-topic.