<p>I've a application Java/Spring boot that is running in a Kubernetes pod, the logs is configure to stdout, fluentd get logs from default path:</p>

<pre><code>&lt;source&gt;
 @type tail
 path /var/log/containers/*.log
 pos_file /pos/containers.pos
 time_key time
 time_format %Y-%m-%dT%H:%M:%S.%NZ
 tag kubernetes.*
 format json
 read_from_head true
&lt;/source&gt;
</code></pre>

<p>In my logback xml configs i've a appender json file:
</p>

<pre><code>&lt;appender name="jsonAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
    &lt;file&gt;${LOG_PATH}/spring-boot-logger.log&lt;/file&gt;
    &lt;encoder class="net.logstash.logback.encoder.LogstashEncoder"/&gt;
    &lt;rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"&gt;
        &lt;maxIndex&gt;1&lt;/maxIndex&gt;
        &lt;fileNamePattern&gt;${LOG_PATH}.%i&lt;/fileNamePattern&gt;
    &lt;/rollingPolicy&gt;
    &lt;KeyValuePair key="service" value="java-app" /&gt;
    &lt;triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"&gt;
        &lt;MaxFileSize&gt;1MB&lt;/MaxFileSize&gt;
    &lt;/triggeringPolicy&gt;
&lt;/appender&gt;
</code></pre>

<p>How do I integrate this separate log file other than stdout in my Kubernete settings along with Fluentd, to send my json logs in a different path</p>

Pedro Henrique
<ol>
<li>In the dockerfile for the spring boot app create a directory where logs will be written</li>
<li>In the logback xml file have a FileAppender which will write logs in that directory path</li>
<li>Have the logback xml file as part of the jar file in <code>resources</code> folder.</li>
<li>Add Fluentd sidecar into the pod spec of the spring boot app</li>
<li>Configure Fluentd sidecar to tail logs from the log file written in that directory path.</li>
</ol>
