Skip to content

Commit

Permalink
system: add traefik access log to lograte
Browse files Browse the repository at this point in the history
Does not seem to be covered by Traefik's internal log rotation.
  • Loading branch information
saltydk committed Dec 11, 2023
1 parent 3ec5319 commit c275c8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
12 changes: 12 additions & 0 deletions roles/system/tasks/subtasks/logrotate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
notifempty
create 644 {{ user.name }} {{ user.name }}
}
- path: "traefik"
content: |
/opt/traefik/access.log {
rotate {{ traefik_log_max_backups }}
size {{ traefik_max_log_size }}
missingok
notifempty
postrotate
docker kill --signal="USR1" traefik
endscript
create 644 {{ user.name }} {{ user.name }}
}
- name: Logrotate | Add items to '/etc/logrotate.d'
ansible.builtin.blockinfile:
Expand Down
5 changes: 5 additions & 0 deletions roles/traefik/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ traefik_docker_commands_default:
- "--log=true"
- "--log.level={{ traefik_log_level }}"
- "--log.filepath=/etc/traefik/traefik.log"
- "--log.maxsize={{ traefik_log_max_size }}"
- "--log.maxbackups={{ traefik_log_max_backups }}"
- "--log.maxage={{ traefik_log_max_age }}"
- "--log.compress={{ traefik_log_compress }}"
- "--log.nocolor=true"
- "--accesslog={{ traefik_access_log }}"
- "--accesslog.fields.names.StartUTC=drop"
- "--accesslog.fields.headers.names.User-Agent=keep"
Expand Down
7 changes: 0 additions & 7 deletions roles/traefik/templates/dynamic.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,3 @@ http:
serversTransports:
skipverify:
insecureSkipVerify: true

log:
noColor: true
maxSize: {{ traefik_log_max_size }}
maxBackups: "{{ traefik_log_max_backups }}"
maxAge: "{{ traefik_log_max_age }}"
compress: "{{ traefik_log_compress }}"

0 comments on commit c275c8c

Please sign in to comment.