Rotate logs for docker containers
search cancel

Rotate logs for docker containers

book

Article ID: 117778

calendar_today

Updated On: 10-04-2023

Products

CA API Developer Portal CA API Gateway

Issue/Introduction



The users would like to do rotate logs of the containers docker.
For example, one file by day.
actually :
only one file : 434f2de4e0877d28a1f6c9e36da953651c966d405381eb36284e029aab147c40-json.log

{"log":"MAC verified OK\n","stream":"stderr","time":"2018-09-21T14:15:15.152799419Z"}
{"log":"MAC verified OK\n","stream":"stderr","time":"2018-09-21T14:15:15.159411411Z"}
{"log":"MAC verified OK\n","stream":"stderr","time":"2018-09-21T14:15:15.164976812Z"}
{"log":"2018/09/21 14:15:15 [warn] 1#1: duplicate MIME type \"text/html\" in /etc/nginx/gzip.nginx:21\n","stream":"stderr","time":"2018-09-21T14:15:15.194723
794Z"}
{"log":"nginx: [warn] duplicate MIME type \"text/html\" in 

Environment

ENV: Portal 9.2 

Resolution

You can put rotation configuration in this file : 
[root@<host_name> nmon]# more /etc/logrotate.conf 
# see "man logrotate" for details 
# rotate log files weekly 
#weekly 
daily 

# keep 4 weeks worth of backlogs 
rotate 28 

# create new (empty) log files after rotating old ones 
create 

# use date as a suffix of the rotated file 
Dateext