<p>I have a problem about docker log setting and wonder if anyone here could help me.
my docker generates a lot of logs, so I set up a rolling update for it, the settings are as follows:</p>

<pre><code>  "log-driver": "json-file",
  "log-level": "warn",
  "log-opts": {
    "max-file": "10",
    "max-size": "100m"
  },
</code></pre>

<p>In this way, its log collection will be as follows:
<a href="https://i.stack.imgur.com/YSvT4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YSvT4.jpg" alt="enter image description here"></a></p>

<p>and when I use <code>kubectl logs</code>, it only read the latest file, which means that at some time, when the log file is just 100M, the latest file will be empty. I wonder if I have a way to read the latest 100M log every time, rather than the latest file. Or how to configure it? Docker can put the latest 100m log in the latest file.</p>

<p>Thanks a lot~</p>

<p>According to the K8S Documentation what you describe is standard behavior and can't be modified:</p>

<p><a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/" rel="nofollow noreferrer">Logging at the node level</a></p>

<blockquote>
  <p>Note: Currently, if some external system has performed the rotation, only the contents of the latest log file will be available through kubectl logs. E.g. if there’s a 10MB file, logrotate performs the rotation and there are two files, one 10MB in size and one empty, kubectl logs will return an empty response.</p>
</blockquote>

<p>I recommend introducing log aggregation to your cluster with a daemon set, e.g. <a href="https://docs.fluentd.org/v/0.12/articles/kubernetes-fluentd" rel="nofollow noreferrer">Fluentd</a> with <a href="https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-quickstart.html" rel="nofollow noreferrer">ElasticSearch and Kibana</a>.</p>
