Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DockerLogsContainer does not copy container output to stdout if used with tee (pipe) #1181

Open
tkrah opened this issue Jun 5, 2023 · 8 comments
Labels

Comments

@tkrah
Copy link
Contributor

tkrah commented Jun 5, 2023

If using e.g. this task:

tasks.register('logContainer', DockerLogsContainer) {
    dependsOn startContainer
    targetContainerId tasks.startContainer.getContainerId()
    follow = true
    tailAll = true
}

it does copy the content of "docker logs -f XXX" to the gradle stdout like expected if you run:

gradle logContainer

But if you run:

gradle logContainer | tee output.txt

where I would expect the same behavior just that it will be on stdout and on output.txt the output.txt does miss the whole stdout output from the container.
The last thing in the output.txt is:

> Task :server:logContainer
Logs for container with ID 'fba05c3c2ac7a094ec9abde34bab34cc4174a6f143df762c9f2c2d2c99893839'.

and that's all - the container output is missing.

The whole output is also not printed to stdout while the container logs does show it (observed with docker logs -f) but only when the container has finished.

I would expect that tee is transparent here like it is for other tools which write something to stdout.

Reproducer:

Just run a logContainer image which does output something to stdout and use tee to pipe it to a file too.

Your Environment

JDK17, Gradle 8.1.1, plugin version 9.3.1.

@bmuschko
Copy link
Owner

It's possible that the implementation of the task doesn't properly flush the stream. Would you be interested in investigating the issue?

@bmuschko bmuschko added the bug label Jun 18, 2023
@bmuschko
Copy link
Owner

bmuschko commented Aug 1, 2023

We have a functional test for this: `DockerLogsContainerFunctionalTest."Can start a container and watch logs". We'd have to see your specific use case and the output you'd expect to see. Do you have a reproducible example?

@tkrah
Copy link
Contributor Author

tkrah commented Aug 1, 2023

I do:

import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import com.bmuschko.gradle.docker.tasks.container.DockerLogsContainer
import com.bmuschko.gradle.docker.tasks.container.DockerRemoveContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
import com.bmuschko.gradle.docker.tasks.image.DockerPullImage

plugins {
id 'base'
id 'com.bmuschko.docker-remote-api' version '9.3.1'
}

def dockerRegistryPull = 'XXXX'

tasks.register('pullImage', DockerPullImage) {
    image = "${dockerRegistryPull}/tomcat:10"
}

tasks.register('createContainer', DockerCreateContainer) {
    dependsOn('pullImage')
    targetImageId tasks.pullImage.getImage()
}

tasks.register('startContainer', DockerStartContainer) {
    dependsOn createContainer
    targetContainerId tasks.createContainer.getContainerId()
}

tasks.register('logContainer', DockerLogsContainer) {
    dependsOn startContainer
    targetContainerId tasks.startContainer.getContainerId()
    follow = true
    tailAll = true
}

Now run gradle logContainer and you get this:

Logs for container with ID 'f03d075e6244dacdd056541331d0cc168acd55f027f231a72961da8248c891b2'.
01-Aug-2023 05:58:23.631 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.1.11

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 6 2023 13:45:39 UTC

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.11.0

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1.42-060142-generic

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /opt/java/openjdk

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           17.0.8+7

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Eclipse Adoptium

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat

01-Aug-2023 05:58:23.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties

01-Aug-2023 05:58:23.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

01-Aug-2023 05:58:23.643 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.4] using APR version [1.7.0].

01-Aug-2023 05:58:23.645 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]

01-Aug-2023 05:58:23.785 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:23.799 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [268] milliseconds

01-Aug-2023 05:58:23.830 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]

01-Aug-2023 05:58:23.830 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.1.11]

01-Aug-2023 05:58:23.837 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:23.845 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [46] milliseconds

01-Aug-2023 05:58:54.974 INFO [Thread-1] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:54.978 INFO [Thread-1] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]

01-Aug-2023 05:58:54.978 INFO [Thread-1] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:54.980 INFO [Thread-1] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:59.892 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.1.11

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 6 2023 13:45:39 UTC

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.11.0

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1.42-060142-generic

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /opt/java/openjdk

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           17.0.8+7

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Eclipse Adoptium

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat

01-Aug-2023 05:58:59.903 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat

01-Aug-2023 05:58:59.903 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

01-Aug-2023 05:58:59.904 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.4] using APR version [1.7.0].

01-Aug-2023 05:58:59.906 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]

01-Aug-2023 05:59:00.051 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:59:00.065 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [270] milliseconds

01-Aug-2023 05:59:00.093 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]

01-Aug-2023 05:59:00.094 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.1.11]

01-Aug-2023 05:59:00.100 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:59:00.108 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [42] milliseconds

01-Aug-2023 06:01:15.249 INFO [Thread-1] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:01:15.254 INFO [Thread-1] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]

01-Aug-2023 06:01:15.255 INFO [Thread-1] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:01:15.257 INFO [Thread-1] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:10:55.960 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.1.11

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 6 2023 13:45:39 UTC

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.11.0

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1.42-060142-generic

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /opt/java/openjdk

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           17.0.8+7

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Eclipse Adoptium

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat

01-Aug-2023 06:10:55.969 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties

01-Aug-2023 06:10:55.969 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

01-Aug-2023 06:10:55.969 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

01-Aug-2023 06:10:55.972 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.4] using APR version [1.7.0].

01-Aug-2023 06:10:55.974 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]

01-Aug-2023 06:10:56.112 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:10:56.126 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [267] milliseconds

01-Aug-2023 06:10:56.155 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]

01-Aug-2023 06:10:56.155 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.1.11]

01-Aug-2023 06:10:56.162 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:10:56.169 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [43] milliseconds

And now run it with gradle logContainer | tee test.txt and you will get only this:

Logs for container with ID 'f03d075e6244dacdd056541331d0cc168acd55f027f231a72961da8248c891b2'.
01-Aug-2023 05:58:23.631 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.1.11

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 6 2023 13:45:39 UTC

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.11.0

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux

01-Aug-2023 05:58:23.633 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1.42-060142-generic

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /opt/java/openjdk

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           17.0.8+7

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Eclipse Adoptium

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat

01-Aug-2023 05:58:23.634 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat

01-Aug-2023 05:58:23.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties

01-Aug-2023 05:58:23.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat

01-Aug-2023 05:58:23.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

01-Aug-2023 05:58:23.643 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.4] using APR version [1.7.0].

01-Aug-2023 05:58:23.645 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]

01-Aug-2023 05:58:23.785 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:23.799 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [268] milliseconds

01-Aug-2023 05:58:23.830 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]

01-Aug-2023 05:58:23.830 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.1.11]

01-Aug-2023 05:58:23.837 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:23.845 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [46] milliseconds

01-Aug-2023 05:58:54.974 INFO [Thread-1] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:54.978 INFO [Thread-1] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]

01-Aug-2023 05:58:54.978 INFO [Thread-1] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:54.980 INFO [Thread-1] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:58:59.892 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.1.11

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 6 2023 13:45:39 UTC

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.11.0

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1.42-060142-generic

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /opt/java/openjdk

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           17.0.8+7

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Eclipse Adoptium

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat

01-Aug-2023 05:58:59.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

01-Aug-2023 05:58:59.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat

01-Aug-2023 05:58:59.903 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat

01-Aug-2023 05:58:59.903 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

01-Aug-2023 05:58:59.904 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.4] using APR version [1.7.0].

01-Aug-2023 05:58:59.906 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]

01-Aug-2023 05:59:00.051 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:59:00.065 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [270] milliseconds

01-Aug-2023 05:59:00.093 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]

01-Aug-2023 05:59:00.094 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.1.11]

01-Aug-2023 05:59:00.100 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

01-Aug-2023 05:59:00.108 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [42] milliseconds

01-Aug-2023 06:01:15.249 INFO [Thread-1] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:01:15.254 INFO [Thread-1] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]

01-Aug-2023 06:01:15.255 INFO [Thread-1] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:01:15.257 INFO [Thread-1] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:10:55.960 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.1.11

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 6 2023 13:45:39 UTC

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.11.0

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1.42-060142-generic

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /opt/java/openjdk

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           17.0.8+7

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Eclipse Adoptium

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat

01-Aug-2023 06:10:55.963 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat

01-Aug-2023 06:10:55.969 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties

01-Aug-2023 06:10:55.969 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

01-Aug-2023 06:10:55.969 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat

01-Aug-2023 06:10:55.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp

01-Aug-2023 06:10:55.972 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.4] using APR version [1.7.0].

01-Aug-2023 06:10:55.974 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]

01-Aug-2023 06:10:56.112 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:10:56.126 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [267] milliseconds

01-Aug-2023 06:10:56.155 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]

01-Aug-2023 06:10:56.155 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.1.11]

01-Aug-2023 06:10:56.162 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:10:56.169 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [43] milliseconds

01-Aug-2023 06:11:38.554 INFO [Thread-1] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:11:38.559 INFO [Thread-1] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]

01-Aug-2023 06:11:38.559 INFO [Thread-1] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:11:38.563 INFO [Thread-1] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]

01-Aug-2023 06:11:44.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.1.11

01-Aug-2023 06:11:44.282 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 6 2023 13:45:39 UTC

01-Aug-2023 06:11:44.282 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.11.0

01-Aug-2023 06:11:44.283 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux

01-Aug-2023 06:11:44.283 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1.42-060142-generic

01-Aug-2023 06:11:44.283 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

01-Aug-2023 06:11:44.283 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /opt/java/openjdk

01-Aug-2023 06:

The console output will stop somewhere in between while docker logs -f $container have all output.
Additionally the file test.txt will have no output and only does have this:

> Task :pullImage
Pulling image 'XXXX/tomcat:10' from XXXX.

> Task :createContainer UP-TO-DATE

> Task :startContainer
Starting container with ID 'f03d075e6244dacdd056541331d0cc168acd55f027f231a72961da8248c891b2'.

> Task :logContainer
Logs for container with ID 'f03d075e6244dacdd056541331d0cc168acd55f027f231a72961da8248c891b2'.

Additionally in the log output in contrast to docker logs after each line there is another empty new line in between.

@bmuschko
Copy link
Owner

bmuschko commented Aug 1, 2023

Was the second command meant to be a Gradle command? docker logContainer | tee test.txt. Be aware that the task has a field named sink for writing the output to a file. That's the one you should use for that purpose.

RE: Empty new lines. I don't see anything in the task's implementation that would cause it. But I didn't dig very deep. As mentioned before, I am not planning to look into this. If you want a fix then you'll need to provide a PR.

@tkrah
Copy link
Contributor Author

tkrah commented Aug 1, 2023

Yeah sorry, my fault, that should read gradle. I don't want to use a sink, I want to look at stdout and pipe it at the same time to a file - classical tee usage.

@bmuschko
Copy link
Owner

bmuschko commented Aug 1, 2023

I actually see multiple concerns here:

  1. Bug: Extra new lines
  2. Feature request: Being able to write to standard output while at the same time writing to a file
  3. Using tee to capture the full output from the Gradle process (this is probably a general issue with Gradle and not related to this plugin)

@tkrah
Copy link
Contributor Author

tkrah commented Aug 1, 2023

  1. Yeah right, should I open a new bug for that one?
  2. Usually I am not a fan of reinventing the wheel for stuff which worked since ages for that (tee) - but if you think that's the way to go ... .
  3. Might be, did not check if all gradle tasks have that problem - the logContainer could just be the most obvious one where you come around that one here.

@bmuschko
Copy link
Owner

bmuschko commented Aug 1, 2023

Feel free to open a separate issue and change the issue description here. Heads up: I do not have to time to work on it but maybe someone else in the community wants to pick it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants