Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are Traefik logs?

Tags:

docker

traefik

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 protected]"
  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
like image 510
Ray Y Avatar asked Feb 19 '19 22:02

Ray Y


3 Answers

Just add [accessLog] to your traefik.toml file and you are fine.

like image 145
Andromeda Avatar answered Sep 20 '22 04:09

Andromeda


I am sharing a docker-compose file, which will create a volume for both access logs and service logs:

"networks":
  "network":
    "external":
      "name": "appliance"
"services":
  "container":
    "container_name": "traefik"
    "image": "traefik:1.7.4"
    "networks":
    - "network"
    "ports":
    - "80:80"
    - "443:443"
    - "8099:8099"
    "restart": "always"
    "volumes":
    - "/var/run/docker.sock:/var/run/docker.sock"
    - "{pwd}/traefik.toml:/traefik.toml"
    - "{pwd}/acme.json:/acme.json"
    - "logs:/var/log/traefik"
"version": "3.4"
"volumes":
  "logs":
    "name": "traefik_logs"

Add the log location in traefik.toml as follows:

[accessLog]
filePath = "/var/log/traefik/access.log"
like image 35
Anish Varghese Avatar answered Sep 24 '22 04:09

Anish Varghese


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

docker-compose log -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 protected]"
  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
like image 34
ldez Avatar answered Sep 22 '22 04:09

ldez