服务器运行日志在哪里: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 st 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:
    stname: 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
8

若要查看 stdout 事件中的日志,请运行docker-compose up -d

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

FYI 路径./traefik.log位于 Traefik 容器内。

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

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

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

version: '3'
services:
  traefik:
    stname: 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
2

只需将[accessLog]添加到您的traefik.toml文件中,您就可以了。

2

我正在共享一个 docker-compose 文件,该文件将为访问日志和服务日志创建一个卷:

"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"

traefik.toml中添加日志位置,如下所示:

[accessLog]
filePath = "/var/log/traefik/access.log"

本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处

(525)
电子营业执照小程序:验证驾驶执照号码(uiia.org)
下一篇

相关推荐

  • java写xml:Hello World!

    示例示例Java可以通过DOM(文档对象模型)、SAX(简单应用程序接口)和StAX(流式API)等API来写入XML文件。以下是使用DOM API写入XML文件的示例代码:…

    2023-08-18 10:20:24
    0 16 62
  • U盘安装win7找不到驱动程序:Win7:更换驱动程序而不重新启动(driverstore explorer tutorial)

    关于U盘安装win7找不到驱动程序的问题,在driverstore explorer tutorial中经常遇到,我正在调试 Windows 7 下的音频驱动程序。当我需要将其替换为更新版本时,我必须重新启动系统,因为尽管卸载了驱动程序,但 DriverStore 下的当前驱动程序的副本仍被锁定。有没有办法避免重新启动?在 XP 上可能...…

    2023-11-22 15:37:27
    0 20 51
  • Liquor:如何创建带有食品和酒类商店列表的地图

    关于Liquor的问题,在liquor store maps中经常遇到,我正在尝试创建一个比较纽约食品和酒类商店数量的谷歌地图。我对 google maps api 或 places api 没有太多经验,所以我真的很困惑。有没有办法我可以在 NYC 周围放置数百个特定颜色的标记,这样你就知道它是一家食品店 (比如红色),然后相应的酒类商店会有不同的颜色 (蓝色)。我不知道完成此操作的最佳方法。…

    2024-03-19 07:57:04
    0 73 13
  • T ler:Lerumarquivoxml

    关于T ler的问题,在arquivo xml中经常遇到,XML。…

    2024-04-13 03:56:43
    0 64 16
  • 筑业工程资料软件:软件工程理论(engineering theory)

    关于筑业工程资料软件的问题,在engineering theory中经常遇到,在我的职业生涯中,我遇到了两种广泛的理论:物理理论和教育 / 管理理论:…

    2024-02-15 04:22:11
    0 73 85
  • 运营sop:SOP中的布尔表达式(sop expression)

    关于运营sop的问题,在sop expression中经常遇到,我是新来的布尔表达式。…

    2023-11-18 13:33:29
    0 52 20
  • 速卖通开店流程:BPMN2.0通过中间事件可视化流程(bpmn intermediate event)

    关于速卖通开店流程的问题,在bpmn intermediate event中经常遇到,关于BPMN2.0通过中间事件可视化流程(bpmn intermediate event)的编程代码示例如下。…

    2024-01-06 02:10:17
    0 44 53
  • Api编程:以编程方式登录到 surveymonkeyapi

    关于Api编程的问题,在survey monkey log in中经常遇到,有没有办法以编程方式登录到调查猴子 api?我的任务是创建一个 C # 应用程序,检索调查响应,并希望从我的代码进行身份验证,可能吗?…

    2023-11-24 01:51:12
    0 98 41

发表评论

登录 后才能评论

评论列表(79条)