I have a custom NAnt task, which writes to console like this:
Console.WriteLine("Status message: " + message);
If I run my buildscript specifying the log to write to (-l:log.txt), the log file doesn’t contain those lines which come from Console.WriteLine. The console window displays all info, obviously.
I know I can redirect the output to log in this way instead:
nant ... > log.txt
But this is not what I’m looking for.
So, the questions are:
- Is it possible to instruct NAnt somehow to grab this console output to its log?
- Should I change the custom task to achieve this?
Your task should use NAnt Logger instead of writing to console. Plain and simple. Redirection won’t work when NAnt is using other loggers, e.g. XML output.