Redirecting symbol to a log file when using docker tool #694
-
I am trying to redirect the logs of a docker process to a file (this normally works running it out of nuke framework)
But when I run that with nuke CreateDatabase this I get an error: C:\ProgramData\DockerDesktop\version-bin\docker.exe logs --since 1m database > C:\git\myproject\build\Logs-Db.txt Usage: docker logs [OPTIONS] CONTAINER Fetch the logs of a container
Usage: docker logs [OPTIONS] CONTAINER Fetch the logs of a container at Nuke.Common.Tooling.ProcessExtensions.AssertZeroExitCode(IProcess process) So Nuke is not too happy with this symbol > of redirection. Can somebody help me with this. Is it actually possible to redirect the logs also to a file that I can then later manipulate? Or if somebody can explain my wrong philosophy around it, since I am new to this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
As far as I understand output redirection is a feature of the command line interpreter, e.g. AFAIK one way to access the output of a tool is to use its return value (of type var outputLines = Docker("logs --since 1m database");
var nonErrorLines = outputLines.Where(line => line.Type == OutputType.Std);
File.WriteAllLines("pathtomyfile", nonErrorLines.Select(line => line.Text)); |
Beta Was this translation helpful? Give feedback.
As far as I understand output redirection is a feature of the command line interpreter, e.g.
cmd.exe
. Nuke just invokes the specified executable and using the>
operator inside the arguments cannot work here.AFAIK one way to access the output of a tool is to use its return value (of type
IReadOnlyCollection<Output>
):