dockertraefik

Where are Traefik logs?


Do you happen to know where the Traefik logs are located? I read the documentation on Traefik and it says it will output to stdout but when I start the docker container with docker-compose up -d it doesn't show anything in stdout after I try the domain name and pull up multiple linked docker containers.

I also tried to specify these:

    [traefikLog]
      filePath = "./traefik.log" #<--Tried this but It doesn't work, file empty and permissions set to 777
    
    [accessLog]
      filePath = "./access.log" #<--Tried this but doesn't work, file empty and permissions set to 777

I'm confused, am I missing something? or is Traefik supposed to be this quiet?

When I run it this is all I see, nothing afterwards.

    # docker-compose up
    Creating traefik ... done
    Attaching to traefik

Attached is my config. Thanks.

traefik/traefik.toml:

    logLevel = "DEBUG"
    defaultEntryPoints = ["http","https"]
    
    [api]
      address = ":8080"
    
    [traefikLog]
      filePath = "./traefik.log" #<--Tried this but It doesn't work
    
    [accessLog]
      filePath = "./access.log" #<--Tried this but doesn't work
    
    [entryPoints]
      [entryPoints.http]
        #redirect ALL http traffic to https 443
        address = ":80"
        [entryPoints.http.redirect]
          entryPoint = "https"
      [entryPoints.https]
        address = ":443"
        [entryPoints.https.tls]
    
    #Let's encrypt setup
    [acme]
      email = "email@email.com"
      storage = "acme.json"
      entryPoint = "https"
      acmeLogging = true
      #When new host is created, request certificate.
      onHostRule = true
      onDemand = false
      [acme.httpChallenge]
        entryPoint = "http"
    
    #Watch Docker, when new containers are created with label create mapping.
    [docker]
      endpoint = "unix:///var/run/docker.sock"
      domain = "exampledomain.net"
      watch = true
      exposedbydefault = false

docker-compose.yml:

    version: '3'
    services:
      traefik:
        hostname: traefik
        domainname: exampledomain.net
        image: traefik:alpine
        command: --api --docker
        container_name: traefik
        networks:
          - nginx-proxy
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - "/var/run/docker.sock:/var/run/docker.sock"
          - "./traefik/traefik.toml:/traefik.toml"
          - "./traefik/acme.json:/acme.json"
        labels:
          - "traefik.enable=true"
          - "traefik.port=8080"
          - "traefik.frontend.rule=Host:monitor.exampledomain.net"
          - "traefik.docker.network=nginx-proxy"
    
    networks:
      nginx-proxy:
        external:
          name: nginx-proxy

Solution

  • To see logs in the stdout event if you run docker-compose up -d:

    docker-compose logs -f
    

    https://docs.docker.com/compose/reference/logs/

    FYI The path ./traefik.log is inside the Traefik container.

    [traefikLog]
      filePath = "./traefik.log" 
    

    With your files (without the section [traefikLog]), I see the logs.


    However, your configuration have some issues:

    version: '3'
    services:
      traefik:
        hostname: traefik
        domainname: exampledomain.net
        image: traefik:v1.7.9-alpine
        # command: --api --docker # <-- don't define the same configuration with CLI and TOML https://docs.traefik.io/basics/#static-traefik-configuration
        container_name: traefik
        networks:
          - nginx-proxy
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - "/var/run/docker.sock:/var/run/docker.sock"
          - "./traefik/traefik.toml:/traefik.toml"
          - "./traefik/acme.json:/acme.json"
        labels:
          - "traefik.enable=true"
          - "traefik.port=8080"
          - "traefik.frontend.rule=Host:monitor.exampledomain.net"
          - "traefik.docker.network=nginx-proxy"
    
    networks:
      nginx-proxy:
        external:
          name: nginx-proxy
    
    logLevel = "DEBUG"
    defaultEntryPoints = ["http","https"]
    
    [api]
      # address = ":8080" <- this options doesn't exist. https://docs.traefik.io/v1.7/configuration/api/
    
    # [traefikLog] # <-- remove because not needed
    #   filePath = "./traefik.log"
    
    # [accessLog] # <-- remove because not needed
    #   filePath = "./access.log"
    
    [entryPoints]
      [entryPoints.http]
        address = ":80"
        [entryPoints.http.redirect]
          entryPoint = "https"
      [entryPoints.https]
        address = ":443"
        [entryPoints.https.tls]
    
    # Let's encrypt setup
    [acme]
      email = "email@email.com"
      storage = "acme.json"
      entryPoint = "https"
      acmeLogging = true
      onHostRule = true
      onDemand = false
      [acme.httpChallenge]
        entryPoint = "http"
    
    [docker]
      endpoint = "unix:///var/run/docker.sock"
      domain = "exampledomain.net"
      # watch = true # <---- useful only for swarm
      exposedbydefault = false