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

Save container output to a file? #90

Closed
psxpaul opened this Issue Jun 22, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@psxpaul
Contributor

psxpaul commented Jun 22, 2017

First, thank you for the great plugin.

Is there an easy way of saving the container output to a file? I see there is a captureContainersOutput option, but that prints the container output to stdout. Since our application can log a lot of things, our gradle build output becomes a fire hose if I turn this on. But frequently, we have tests fail in CI and I would like to see if there were any errors in the application.

I currently have the following code to do this at the end of a build:

composeDown.doFirst {
    mkdir "$buildDir/logs/docker"
    project.exec { ExecSpec e ->
        extension.setExecSpecWorkingDirectory(e)
            e.environment = composeDown.extension.environment
            e.commandLine composeDown.extension.composeCommand('logs', '--no-color', 'app')
            e.standardOutput = new FileOutputStream("$buildDir/logs/docker/app.log")
    }
}

This is somewhat cumbersome though, and relies on the current implementation of the composeDown task. It also doesn't write the log files until the end of the build. Ideally, the captureContainersOutput option could take a file or outputstream to make this easier.

@augi

This comment has been minimized.

Show comment
Hide comment
@augi

augi Jun 23, 2017

Member

Hi, it's not possible to save the container output to a file but I like that feature so I would like to implement it soon (or feel free to prepare a PR).

Member

augi commented Jun 23, 2017

Hi, it's not possible to save the container output to a file but I like that feature so I would like to implement it soon (or feel free to prepare a PR).

psxpaul added a commit to psxpaul/docker-compose-gradle-plugin that referenced this issue Jun 24, 2017

psxpaul added a commit to psxpaul/docker-compose-gradle-plugin that referenced this issue Jun 24, 2017

augi added a commit that referenced this issue Jun 24, 2017

Merge pull request #91 from psxpaul/master
#90 adding option to save container output to a logfile

psxpaul added a commit to psxpaul/docker-compose-gradle-plugin that referenced this issue Jun 26, 2017

augi added a commit that referenced this issue Jun 26, 2017

Merge pull request #92 from psxpaul/master
#90 fix for newlines not printing to file

@psxpaul psxpaul closed this Jun 26, 2017

@antinodes

This comment has been minimized.

Show comment
Hide comment
@antinodes

antinodes Jun 30, 2017

Is there interest in extending this feature to support a separate file per container? Personally, I find it difficult to read the logs when they are all interleaved.

antinodes commented Jun 30, 2017

Is there interest in extending this feature to support a separate file per container? Personally, I find it difficult to read the logs when they are all interleaved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment