Cake Task输出日志到文件 [英] Cake Task output log to file

查看:102
本文介绍了Cake Task输出日志到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 build.cake 文件中有一组任务,我想将控制台的日志输出捕获到日志文件中。我知道可以使用 OnError()函数将错误输出到文件,但我想将所有内容输出到日志文件,而不仅仅是错误。
下面是 build.cake 文件的示例。

I have a set of Tasks inside a build.cake file and I would like to capture the log output from the console into a log file. I know it's possible to use the OnError() function to output errors to file but I would like to output everything to a log file, not just errors. Below is an example of the build.cake file.

#load "SomeTask.cake"
#load "SomeOtherTask.cake"

var target = Argument("target", "Default");

var someTask = Task("SomeTask")
.Does(() =>
{
     SomeMethodInsideSomeTask();
});

var someOtherTask = Task("SomeOtherTask")
.Does(() => 
{
    SomeOtherMethodInsideSomeOtherTask();
});

Task("Default")
.IsDependentOn(someTask)
.IsDependentOn(someOtherTask);

RunTarget(target);

N.B。这些任务未运行任何 MSBuild 命令,因此无法使用 MSBuildFileLogger

N.B. The Tasks are not running any sort of MSBuild commands so it's not possible to use MSBuildFileLogger.

推荐答案

如何将标准输出通过管道传输到文件,即

How about pipe the stdout to a file i.e.


./ build.ps1> log.txt

./build.ps1 > log.txt

这篇关于Cake Task输出日志到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆