Timezone for access logs

Hello, I am getting timezone +0000 in my access logs, I provided TZ env variable in my docker compose, and tried setting command accesslog.fields.names.StartUTC=drop according to docs

However, access logs are still in +0000, time in container is in correct TZ and traefik logs are fine as well, what can be wrong?

Thanks

Any ideas? I tried all options listed in docs, with no luck :confused:

Did you set the log setting in a static config context?

Yes, it is working (logging) perfectly. The only issue is that traefik system logs have correct timezone and access logs don't. I checked timezone of traefik container with date command in a shell inside the container, that is also in the correct timezone, the issue is only with access logs.

Can you show your static config?

Sure! Here it goes:

api:
  dashboard: true
  debug: true

entryPoints:
  web:
    address: ':80'
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https
      middlewares:
        - crowdsec-bouncer@file
    forwardedHeaders:
      trustedIPs:
        - 127.0.0.1/32
        - 172.20.0.0/24
        - 173.245.48.0/20
        - 103.21.244.0/22
        - 103.22.200.0/22
        - 103.31.4.0/22
        - 141.101.64.0/18
        - 108.162.192.0/18
        - 190.93.240.0/20
        - 188.114.96.0/20
        - 197.234.240.0/22
        - 198.41.128.0/17
        - 162.158.0.0/15
        - 104.16.0.0/13
        - 104.24.0.0/14
        - 172.64.0.0/13
        - 131.0.72.0/22
        - '2400:cb00::/32'
        - '2606:4700::/32'
        - '2803:f800::/32'
        - '2405:b500::/32'
        - '2405:8100::/32'
        - '2a06:98c0::/29'
        - '2c0f:f248::/32'
  websecure:
    address: ':443'
    forwardedHeaders:
      trustedIPs:
        - 127.0.0.1/32
        - 172.20.0.0/24
        - 173.245.48.0/20
        - 103.21.244.0/22
        - 103.22.200.0/22
        - 103.31.4.0/22
        - 141.101.64.0/18
        - 108.162.192.0/18
        - 190.93.240.0/20
        - 188.114.96.0/20
        - 197.234.240.0/22
        - 198.41.128.0/17
        - 162.158.0.0/15
        - 104.16.0.0/13
        - 104.24.0.0/14
        - 172.64.0.0/13
        - 131.0.72.0/22
        - '2400:cb00::/32'
        - '2606:4700::/32'
        - '2803:f800::/32'
        - '2405:b500::/32'
        - '2405:8100::/32'
        - '2a06:98c0::/29'
        - '2c0f:f248::/32'
    proxyProtocol:
      trustedIPs:
        - 127.0.0.1/32
        - 172.20.0.0/24
        - 173.245.48.0/20
        - 103.21.244.0/22
        - 103.22.200.0/22
        - 103.31.4.0/22
        - 141.101.64.0/18
        - 108.162.192.0/18
        - 190.93.240.0/20
        - 188.114.96.0/20
        - 197.234.240.0/22
        - 198.41.128.0/17
        - 162.158.0.0/15
        - 104.16.0.0/13
        - 104.24.0.0/14
        - 172.64.0.0/13
        - 131.0.72.0/22
        - '2400:cb00::/32'
        - '2606:4700::/32'
        - '2803:f800::/32'
        - '2405:b500::/32'
        - '2405:8100::/32'
        - '2a06:98c0::/29'
        - '2c0f:f248::/32'
    http:
      middlewares:
        - crowdsec-bouncer@file

providers:
  docker:
    watch: true
    network: traefik
  file:
    filename: /etc/traefik/traefik_dynamic.yml

certificatesResolvers:
  lets-encrypt:
    acme:
      email: #redacted
      storage: /letsencrypt/acme.json
      httpChallenge:
        entryPoint: web

log:
  level: "INFO"
  filePath: "/var/log/traefik/traefik.log"

accessLog:
  filePath: "/var/log/traefik/access.log

Where is the setting from the docs?

accesslog.fields.names.StartUTC=drop

Hint: you can only have one static config, either traefik.yml or command line arguments.

Thank you! It wasn't there since I tested it as a command in my compose, I added it this way in my static config and now it works :grin:

accessLog:
  filePath: "/var/log/traefik/access.log"
  fields:
    names:
      StartUTC: drop

The hint was the key, I didn't know that command and static config were exclusive to each other, thanks for that!

Cheers

My apologies since it is not 100% traefik related, but that was the initial cause for the issue with timezone of the first post. I am having problems with logrotate, which correctly rotates files but I see that it rotates everyday at +0000, is it normal behiaviour? I was blaming access logs for having the wrong timezone (hence the post), but I still see it compressing at +0000 instead of 00:00 of my current (and system's) timezone.

I would assume that logrotate is running on your host, so you need to adjust the settings when it is triggered.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.