# Traefik not writing log files

**URL:** <https://community.traefik.io/t/traefik-not-writing-log-files/1094>\
**Category:** Traefik v1\
**Tags:** docker\
**Created:** [July 31, 2019, 7:09am UTC](https://community.traefik.io/t/traefik-not-writing-log-files/1094 "2019-07-31T07:09:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thepenguinthatwants](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thepenguinthatwants/32/832_2.png) [@thepenguinthatwants](https://community.traefik.io/u/thepenguinthatwants)\
**Post date:** [July 31, 2019, 7:09am UTC](https://community.traefik.io/t/traefik-not-writing-log-files/1094/1 "2019-07-31T07:09:14Z")

</div>

Hi guys!

I have a working docker-compose that uses traefik alpine. I am using debian 9 as the main distro.

The problem is that its not writing any logfiles.

My docker-compose.yml looks like this

```auto
version: "3"

services:
  traefik:
    container_name: traefik
    image: traefik:alpine
    networks:
      - server
    ports:
      - 80:80
      - 443:443
    volumes:
      - /opt/traefik/traefik.toml:/traefik.toml:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /opt/traefik/acme.json:/acme.json
    labels:
      - traefik.enable=true
      - traefik.port=8080
      - traefik.frontend.rule=Host:top.example.xyz
    command:
      - --accessLog=true
      - --logLevel=INFO
      - --accessLog.filePath="/opt/traefik/access.log"
      - --traefikLog.filePath="/opt/traefik/traefik.log"
      - --traefikLog.format="json"
      - --accessLog.format="json"

networks:
  server:
    external: true

```

And traefik.toml

```auto
logLevel = "INFO"
checkNewVersion = true

defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.dashboard]
    address = ":8080"
    [entryPoints.dashboard.auth]
      [entryPoints.dashboard.auth.basic]
        users = ["test:$apr1$k56KsfIu$7RI1JNkmwXpjqyaLPYuIA."]
  [entryPoints.http]
    address = ":80"
      [entryPoints.http.redirect]
        entryPoint = "https"
  [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]

[api]
entrypoint="dashboard"
dashboard = true

[retry]

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "example.xyz"
exposedByDefault = false
watch = true

[acme]
email = "example@example.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
  [acme.httpChallenge]
entryPoint = "http"

```

I am using traefik:alpine and the version is v1.7.12 and I changed my real domain to example.

I've tried different locations for access.log and traefik.log but nothing seems to be created. My purpose is to get it create logfiles so I can implement it with fail2ban.

---

<div class="post-metadata">

**Author:** ![dduportal](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dduportal/32/4_2.png) [@dduportal](https://community.traefik.io/u/dduportal)\
**Post date:** [July 31, 2019, 9:50am UTC](https://community.traefik.io/t/traefik-not-writing-log-files/1094/2 "2019-07-31T09:50:35Z")

</div>

Hi @thepenguinthatwants,where are looking at the log files? It looks like that you did not mount the directory `/opt/traefik` from Traefik's container, so if you are looking on the host machine, this directory won't be visible as docker container have isolated filesystems.

---

<div class="post-metadata">

**Author:** ![dduportal](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dduportal/32/4_2.png) [@dduportal](https://community.traefik.io/u/dduportal)\
**Post date:** [July 31, 2019, 10:03am UTC](https://community.traefik.io/t/traefik-not-writing-log-files/1094/3 "2019-07-31T10:03:43Z")

</div>

Also, there are a few configuration hiccups that should be fixed to avoid any side effects:

- Mixing CLI flags and TOML for the "static configuration" is discouraged (it won't even work with Traefik v2.0). As you are using a `traefik.toml`, I would recommend you to:
  - Remove the section `command:` for the service `traefik` in your `docker-compose.yml`
  - Add the following TOML snippet to `traefik.toml` (transcription of the CLI flags into TOML as described in the reference documentation: \<\>)

```auto
[traefikLog]
  filePath = "/opt/traefik/traefik.log"
  format = "json"

[accessLog]
  filePath = "/opt/traefik/access.log"
  format = "json"

```

I used your snippet to reproduce and traefik writes the logs in this case for sure:

```shell
$ docker-compose up -d
$ docker-compose exec traefik ls -l /opt/traefik
total 8
-rw-r--r-- 1 root root 2195 Jul 31 09:57 access.log
-rw-r--r-- 1 root root 2868 Jul 31 09:57 traefik.log

```

- Also, you should not mount the docker socket in read-only mode: remove the suffix `:ro` for the bind mount of `/var/run/docker.sock` (reference: [https://github.com/containous/traefik/issues/4174#issuecomment-446694416](https://github.com/containous/traefik/issues/4174#issuecomment-446694416)).

---

<div class="post-metadata">

**Author:** ![thepenguinthatwants](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thepenguinthatwants/32/832_2.png) [@thepenguinthatwants](https://community.traefik.io/u/thepenguinthatwants)\
**Post date:** [August 1, 2019, 4:11am UTC](https://community.traefik.io/t/traefik-not-writing-log-files/1094/4 "2019-08-01T04:11:08Z")

</div>

I was looking the log files at /opt/traefik of my server host. You are right I havent mounted the one that should contains logs.. So If I am not wrong then traefik docker image location for logs is /opt/traefik.

Thanks for pointing out this. I found it kinda hard to understand those TOML so I decided mixing those flags. Now I understand where the problem lies.

---

<div class="post-metadata">

**Author:** ![thepenguinthatwants](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thepenguinthatwants/32/832_2.png) [@thepenguinthatwants](https://community.traefik.io/u/thepenguinthatwants)\
**Post date:** [August 1, 2019, 4:15am UTC](https://community.traefik.io/t/traefik-not-writing-log-files/1094/5 "2019-08-01T04:15:45Z")

</div>

I mounted the docker socker read-only because I thought it was for increasing security.

"AFAIK :ro on a unix domain socket just prevent you to rename/remove it" Damns

---

<div class="post-metadata">

**Author:** ![dduportal](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dduportal/32/4_2.png) [@dduportal](https://community.traefik.io/u/dduportal)\
**Post date:** [August 2, 2019, 7:52am UTC](https://community.traefik.io/t/traefik-not-writing-log-files/1094/7 "2019-08-02T07:52:33Z")

</div>

Thanks for the feedback @thepenguinthatwants! Have fun with Traefik 😉
