<p>I've created a Jenkins pipeline and I am running it on GKE (using Kubernetes plugin). In one of the steps I am running java application in one of the containers. Application is writing logs to stdout. I would like to see the logs from this application in Stackdriver. How can I achieve it? Currently I am not able to see these logs in Stackdriver nor in Jenkins logs.</p>
<p>My pipeline:</p>
<pre><code>podTemplate(cloud: 'kubernetes',
        yaml: &quot;&quot;&quot;
apiVersion: v1
kind: Pod
spec:
  securityContext:
    runAsUser: 0
  containers:
  - name: maven
    image: maven:3.6.3-jdk-11
    resources:
      requests:
        cpu: &quot;1&quot;
        memory: &quot;1Gi&quot;
        ephemeral-storage: &quot;20Mi&quot;
      limits:
        cpu: &quot;2&quot;
        memory: &quot;4Gi&quot;
        ephemeral-storage: &quot;1Gi&quot;
    command:
    - cat
    tty: true
&quot;&quot;&quot;
) {
    node(POD_LABEL) {
        stage('Run app') {
            container('maven') {
                sh &quot;java -jar my-app.jar &amp;&quot;
            }
        }
    }
}
</code></pre>
<p>=== EDIT ===</p>
<p>My master Jenkins is installed on one of the GKE pods and each PR validation triggers another pod having the mentioned container with java application. It looks that the jenkins slave agent is gathering the logs (but not attaching them to build log as the java app is run in background).</p>

<p>If you are already running the Jenkin on GCP instance it would be quite easy and directly get the logs to Stackdriver.</p>
<p><a href="https://faun.pub/jenkins-on-google-compute-engine-611bd86e295b" rel="nofollow noreferrer">https://faun.pub/jenkins-on-google-compute-engine-611bd86e295b</a></p>
<p>You can also integrate the Agent with java</p>
<p>Reference : <a href="https://medium.com/google-cloud/java-logging-on-cloud-run-with-stackdriver-9786d6fdbe17" rel="nofollow noreferrer">https://medium.com/google-cloud/java-logging-on-cloud-run-with-stackdriver-9786d6fdbe17</a></p>
<p>You should also checkout using the <a href="https://bluemedora.com/integration/jenkins-logs-in-google-stackdriver/" rel="nofollow noreferrer">Bluemedora</a></p>
