<p>I have java app in k8s and fluentd (daemonset). In fluentd conf:</p>

<pre><code> *`&lt;source&gt;
     @type forward
     port 24224
  &lt;/source&gt;
  &lt;match **&gt;
  @type stdout
  &lt;/match&gt;`*
</code></pre>

<p>I am little bit confused. 
Do I need use fluentd-logger-java lib? I read in docs, that I need add remotehost for fluentd, but here i don't use service in general.
How app will send logs to fluentd pods?</p>

<p>Thanks in advance!</p>

<p>Given that your Java application can log to <code>stdout</code> and <code>stderr</code> you’ll use fluentd to read that log and, in most cases, ship these logs to a system that can aggregate the logs.</p>

<p>This picture, from the <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/" rel="nofollow noreferrer">official docs</a>, shows a common pattern of configuring node-level logging in Kubernetes with e.g. fluentd as Pods deployed with a DaemonSet:</p>

<p><a href="https://i.stack.imgur.com/givOm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/givOm.jpg" alt="enter image description here"></a></p>

<p>In the above picture, the <code>logging-agent</code> will be fluentd and <code>my-pod</code> will be your Pod with a container running your Java app. The <code>Logging Backend</code>, from a fluentd configuration perspective, is optional but of course highly recommended. Basically you can choose to output your logs via fluentd <code>stdout</code>.</p>

<p>For this to function properly fluentd will need read access to the container logs, this is accomplished by mounting the log dir e.g. <code>/var/lib/docker/containers</code> into the fluentd container.</p>

<p>We’ve successfully used <a href="https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-elasticsearch/fluentd-es-configmap.yaml" rel="nofollow noreferrer">this fluentd example ConfigMap</a>, with some modifications to read logs from the nodes and ship them to Elasticsearch. Check out the <code>containers.input.conf</code> part of that ConfigMap for more info on container logs and how to digest them.</p>

<p>Note that you shouldn't need to use the <code>fluentd-logger-java</code> library to start using fluentd, although you could use it as another type of logger in your Java application. Out-of-the-box you should be able to let Java log everything to <code>stdout</code> and <code>stderr</code> and read the logs with fluentd.</p>
