首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Traefik日志在哪里?

Traefik日志在哪里?
EN

Stack Overflow用户
提问于 2019-02-20 06:39:04
回答 3查看 19.8K关注 0票数 9

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

我还尝试指定以下内容:

代码语言:javascript
运行
复制
[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应该是这么安静的?

当我运行它的时候,这是我所看到的,之后什么也看不到。

代码语言:javascript
运行
复制
# docker-compose up
Creating traefik ... done
Attaching to traefik

附件是我的配置。谢谢。

traefik/traefik.toml:

代码语言:javascript
运行
复制
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:

代码语言:javascript
运行
复制
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
EN

Stack Overflow用户

回答已采纳

发布于 2019-02-20 07:34:03

在运行docker-compose up -d时查看标准输出事件中的日志

代码语言:javascript
运行
复制
docker-compose log -f

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

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

代码语言:javascript
运行
复制
[traefikLog]
  filePath = "./traefik.log" 

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

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

代码语言:javascript
运行
复制
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
代码语言:javascript
运行
复制
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
票数 7
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54776024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档