# How can I write access log as file in k8s ingress installed by helm chart

**URL:** <https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119>\
**Category:** Traefik v2\
**Tags:** kubernetes-ingress, file\
**Created:** [April 12, 2022, 2:30am UTC](https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119 "2022-04-12T02:30:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joey-yoonsung](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/joey-yoonsung/32/5187_2.png) [@joey-yoonsung](https://community.traefik.io/u/joey-yoonsung)\
**Post date:** [April 12, 2022, 2:30am UTC](https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119/1 "2022-04-12T02:30:20Z")

</div>

Hi.

I want to collect access log by collector that read all logfiles in /var/log path and run as daemonset in a namespace.

I installed traefik as helm chart - [GitHub web editor](https://github.dev/traefik/traefik-helm-chart/tree/master/traefik)

I add mount to volumes and additionalVolumeMounts in values.yaml.

```yaml
deployment:
  additionalVolumes:
    - name: traefik-logs
      emptyDir: {}

additionalVolumeMounts:
  - name: traefik-logs
    mountPath: /var/log

```

I add filePath in `log.general` & `log.access`

```yaml
logs:
  general:
    level: ERROR
    filePath: /var/log/traefik.log
  access:
    filePath: /var/log/traefik-access.log

```

But, there is any log file in /var/log.  
There is no config as parameter on process related to log file.

```auto
$ ps aux | grep traefik

```

1 65532 0:00 traefik traefik --global.checknewversion --global.sendanonymoususage --entrypoints.metrics.address=:9100/tcp --entrypoints.traefik.address=:9000/tcp --entrypoints.web.address=:8000/tcp --entrypoints.websecure.address=:8443/tcp --api.dashboard=true --ping=true --metrics.prometheus=true --metrics.prometheus.entrypoint=metrics --providers.kubernetescrd --providers.kubernetesingress --accesslog=true --accesslog.format=json --accesslog.fields.defaultmode=keep --accesslog.fields.headers.defaultmode=keep

I tested it again to fix mount path to `/var/log/traefik`. /var/log/traefik dir is created. Volume seems to be amounted. But traefik filepath config seems to be not working.

---

<div class="post-metadata">

**Author:** ![jakubhajek](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jakubhajek/32/3389_2.png) [@jakubhajek](https://community.traefik.io/u/jakubhajek)\
**Post date:** [April 12, 2022, 4:24am UTC](https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119/2 "2022-04-12T04:24:43Z")

</div>

Hello @joey-yoonsung

Did you check the path /var/log directly into Traefik container? The logs files should be created and stored inside a container.

---

<div class="post-metadata">

**Author:** ![joey-yoonsung](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/joey-yoonsung/32/5187_2.png) [@joey-yoonsung](https://community.traefik.io/u/joey-yoonsung)\
**Post date:** [April 12, 2022, 4:47am UTC](https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119/3 "2022-04-12T04:47:43Z")

</div>

@jakubhajek

Yes. there is.  
I access the container as shell like bellow

```shell
kubectl get pod | grep traefik  ✔  1h 53m 43s  ladp-vks-120-dev ⎈  13:45:38 
traefik-7788b7c8c7-x9w24 1/1 Running 0 114m

```

```auto
kubectl exec -it traefik-7788b7c8c7-x9w24 /bin/sh

```

```auto
 $ cd var/log
/var/log $ ls -al
total 0
drwxrwsrwx 2 root 65532 6 Apr 12 02:50 .
drwxr-xr-x 1 root root 21 Apr 12 02:50 ..

```

---

<div class="post-metadata">

**Author:** ![joey-yoonsung](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/joey-yoonsung/32/5187_2.png) [@joey-yoonsung](https://community.traefik.io/u/joey-yoonsung)\
**Post date:** [April 12, 2022, 5:19am UTC](https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119/4 "2022-04-12T05:19:44Z")

</div>

I tried to set more change of configurations, but there is no different.

`filePath` key in `logs`, `logs.general`, `logs.access` seems to be ignored.

Very hard to configure traefik in k8s because the official document doesn't care about config in k8s.

---

<div class="post-metadata">

**Author:** ![joey-yoonsung](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/joey-yoonsung/32/5187_2.png) [@joey-yoonsung](https://community.traefik.io/u/joey-yoonsung)\
**Post date:** [April 12, 2022, 11:49am UTC](https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119/5 "2022-04-12T11:49:35Z")

</div>

I found it!

`filePath` is not working in `logs` , `logs.general` , `logs.access`.

The `filepath` can be set by additionalArguments in values.yaml

- It's guide here [CLI - Traefik](https://doc.traefik.io/traefik/reference/static-configuration/cli/)

```yaml
deployment:
  additionalVolumes:
    - name: traefik-logs
      emptyDir: {}

additionalVolumeMounts:
  - name: traefik-logs
    mountPath: /var/log/traefik

additionalArguments:
  - "--log.filepath=/var/log/traefik/traefik.log"
  - "--accesslog.filepath=/var/log/traefik/traefik-access.log"

```

Then the process run with these parameters.

```bash
ps aux | grep traefik

```

```
1 65532 0:00 traefik traefik --global.checknewversion --global.sendanonymoususage --entrypoints.metrics.address=:9100/tcp --entrypoints.traefik.address=:9000/tcp --entrypoints.web.address=:8000/tcp --entrypoints.websecure.address=:8443/tcp --api.dashboard=true --ping=true --metrics.prometheus=true --metrics.prometheus.entrypoint=metrics --providers.kubernetescrd --providers.kubernetesingress --accesslog=true --accesslog.format=json --accesslog.fields.defaultmode=keep --accesslog.fields.headers.defaultmode=keep --log.filepath=/var/log/traefik/traefik.log --accesslog.filepath=/var/log/traefik/traefik-access.log

```

But it has limitations. The stdout that streamed the traefik app log and access log both before don't stream access log anymore.

---

<div class="post-metadata">

**Author:** ![jakubhajek](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jakubhajek/32/3389_2.png) [@jakubhajek](https://community.traefik.io/u/jakubhajek)\
**Post date:** [April 12, 2022, 12:00pm UTC](https://community.traefik.io/t/how-can-i-write-access-log-as-file-in-k8s-ingress-installed-by-helm-chart/14119/6 "2022-04-12T12:00:53Z")

</div>

You can have a look at the workshop we have prepared to let Kubernetes users start with Traefik:

[![](https://img.youtube.com/vi/CL5Cxxz-yHo/maxresdefault.jpg "Workshop: Getting Started with Traefik") ](https://www.youtube.com/watch?v=CL5Cxxz-yHo)
