docker-Traefik日志在哪里?

您是否知道Traefik日志位于何处?我阅读了Traefik上的文档,并说它将输出到stdout,但是当我使用docker-compose up -d启动docker容器时,在尝试域名并拉出多个链接的docker容器后,stdout中没有任何显示.

我也尝试指定这些:

[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

我很困惑,我错过了什么吗?还是Traefik应该这么安静?

当我运行它时,这就是我所看到的,之后什么也没有.

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

附件是我的配置.谢谢.

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
最佳答案
要在stdout事件中查看日志(如果您运行docker-compose up -d):

docker-compose log -f

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

仅供参考,路径./traefik.log在Traefik容器内.

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

使用您的文件(没有[traefikLog]部分),我看到了日志.

但是,您的配置存在一些问题:

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

相关文章

最近一直在开发Apworks框架的案例代码,同时也在一起修复Apw...
最近每天都在空闲时间努力编写Apworks框架的案例代码WeText。...
在《Kubernetes中分布式存储Rook-Ceph部署快速演练》文章中,...
最近在项目中有涉及到Kubernetes的分布式存储部分的内容,也...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...