Logging
Cake provides logging aliases for writing log messages to the console.
Verbosity Levels
Cake supports the following verbosity levels, which control how much information is logged:
| Level | Description |
|---|---|
Quiet |
Only errors are shown |
Minimal |
Errors and warnings |
Normal |
Default level |
Verbose |
Detailed output |
Diagnostic |
Most detailed output |
You can set the verbosity level using the --verbosity switch:
dotnet cake --verbosity=diagnostic
Logging Aliases
Cake provides built-in aliases for writing log messages at different levels:
// Information
Information("This is an informational message.");
// Warning
Warning("This is a warning.");
// Error
Error("This is an error.");
// Verbose
Verbose("This is a verbose message.");
// Debug
Debug("This is a debug message.");
Advanced output
Cake ships with Spectre.Console, which provides advanced functionality to output content to the console, like progress bars, spinners, tables, trees, bar charts or FIGlet text.
Use the AnsiConsole class to render advanced widgets to the console.
See Spectre.Console documentation for details.
Cake is built against a specific version of Spectre.Console. If you intend to use Spectre.Console directly in your scripts (e.g., via the #addin directive), you should ensure that you use the same version that Cake uses to avoid assembly versioning conflicts and potential FileLoadException errors.
For more details on why this is necessary, see GitHub issue cake-build/cake#3260.
