Traefik v2 access.log don't created

I want understand why my access.log file was not created.
All work but i don't have the access.log file.
This is my docker-compose file :

version: "3"


    image: traefik:v2.0.6
    container_name: "traefik"
    restart: always
      - "80:80"
      - "443:443"
      - --global.checkNewVersion=true
      - --global.sendAnonymousUsage=true
      - --entryPoints.web.address=:80
      - --entryPoints.websecure.address=:443
      - --log.level=DEBUG
      #- --log.filePath=/home/asterix/traefik.log
      #- --log.format=json
      - --accesslog=true
      - --accesslog.filepath=/home/asterix/access.log
      - --accesslog.bufferingsize=100
      - --accesslog.format=json
      - --api
      - --ping
      - --certificatesresolvers.myhttpchallenge.acme.httpchallenge=true
      - --certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web
      - --providers.docker.exposedByDefault=false
      # -
      # - --providers.docker.swarmMode=true
      - /var/run/docker.sock:/var/run/docker.sock
      - "./letsencrypt:/letsencrypt"
      - "traefik.enable=true"
      - "traefik.http.routers.traefik_https.rule=Host(``)"
      - "traefik.http.routers.traefik_https.entrypoints=websecure"
      #- "traefik.http.routers.traefik_https.tls=true"
      #- "traefik.http.routers.traefik_https.tls.certResolver=letsencrypt"
      - "traefik.http.routers.traefik_https.tls.certresolver=myhttpchallenge"
      - "traefik.http.routers.traefik_https.service=api@internal"
      - "traefik.http.routers.traefik_https.middlewares=traefik-auth"
      # - ""
      # required only for swarm
      - "traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$apr1$$a6P97nso$$5eGredHgC8EuQpV0sh1Ge0"
      - "traefik.http.routers.http_traefik.rule=Host(``)"
      - "traefik.http.routers.http_traefik.entrypoints=web"
      - "traefik.http.routers.http_traefik.middlewares=https_redirect"
      - "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.https_redirect.redirectscheme.permanent=true"

Thanks for using Træfik.

Does your /home/asterix/access.log file exists ?
As I can see, you didn't mapped the log file volume to the container
See this to view how to do that (I used toml declaration but it works with commands instead)


It's work now ! Thank's you so much @darkweak !

thanks for the solution, I faced the same issue but where is that documented that you have to mapped this path?
I assume, when the commands


are added, traefik does that by himself.
By the way, my docker-compose.yml lists the commands without leading -,
so instead of

- --accesslog=true
- --accesslog.filepath=/home/asterix/access.log

I do


Is there any important difference?

Hello @PackElend

I don't found in the documentation ( where we must mapped the path for access.log.

For the difference between :

- --accesslog=true
- --accesslog.filepath=/home/asterix/access.log

I do


I think it's not important.

I hope you have helped.

You do not have to map the path if you do not need to access directly from the host (that is you are happy to access it in the container context, e.g with docker exec).

If you do, I find this part of the docker documentation quite comprehensive:

As far as the command goes it's a difference between the list and string format as described here:

Yaml spec (See section "2.1. Collections" of version 1.2 for different ways to represent a list in yaml) and are also useful in order to understand how yaml handles lists and strings.

It makes a difference when you want to insert comments between the commands, see linux - Use inline comments in docker-compose command - Stack Overflow.

Checking the content of a yaml file is easy thing using Online YAML Parser
So I figured out how it gets accepted by the parser:

    # The official v2.0 Traefik docker image
    image: traefik:latest 
    #image: traefik:v2.0
    container_name: "traefik"       
    # to work with custom traefil configuration file you have to declare the local path and mount the location on the host, see volume section
    - --configFile=/etc/traefik/traefik-config.yaml
    # another comment
    - --next command #1
    - --and again
1 Like

thanks and see answer above :slight_smile:

I have figured today that traefik cannot write file in /opt/* and doesn't tell...

awesome thanks for this!

1 Like