<p>In my k8s environment where spring-boot applications runs, I checked log location in <code>/var/log</code> and <code>/var/lib</code> but both empty. Then I found log location in <code>/tmp/spring.log</code> . It seems this the default log location. My problem are</p>
<ol>
<li>How <code>kubectl log</code> knows it should read logs from <code>/tmp</code> location. I get log output on <code>kubectl logs</code> command.</li>
<li>I have fluent-bit configured where it has input as</li>
</ol>
<p>following</p>
<pre><code> [INPUT]
    Name              tail
    Tag               kube.dev.*
    Path              /var/log/containers/*dev*.log
    DB                /var/log/flb_kube_dev.db
</code></pre>
<p>This suggest it should reads logs from <code>/var/log/containers/</code> but it does not have logs. However i am getting fluent-bit logs successfully. What am i missing here ?</p>

Viraj
<p>Docker logs only contain the logs that are dumped on STDOUT by your container's process with PID 1 (your container's <code>entrypoint</code> or <code>cmd</code> process).</p>
<p>If you want to see the logs via <code>kubectl logs</code> or <code>docker logs</code>, you should redirect your application logs to STDOUT instead of file <code>/tmp/spring.log</code>. <a href="https://serverfault.com/a/634296">Here's</a> an excellent example of how this can achieved with minimal effort.</p>
<hr />
<p>Alternatively, you can also use <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">hostPath</a> volumeMount. This way, you can directly access the log from the path on the host.</p>
<h5>Warning when using hostPath volumeMount</h5>
<p>If the pod is shifted to another host due to some reason, you logs will not move along with it. A new log file will be created on this new host at the same path.</p>
