loading

Log levels

Log / Info / Warn / Error / Debug

The five standard severity levels, each styled and filterable in DevTools. All accept any number of values, including objects.

C#
await console.Log("General output:", value);
await console.Info("Informative:", value);
await console.Warn("Warning:", value);
await console.Error("Error:", value);
await console.Debug("Debug level:", value);
Live sample
Message (sent by most buttons on this page)
log levels output
Results will appear here when you interact with the samples.

Assertions & inspection

Assert / Dir / Dirxml

Assert logs only when its condition is false. Dir prints an interactive property listing of an object, while Dirxml renders a DOM node as an expandable HTML tree.

C#
await console.Assert(items.Count > 0, "The list should never be empty!");

await console.Dir(someObject);
await console.Dirxml(elementReference);
Live sample
assertions output
Results will appear here when you interact with the samples.

Tabular data

Table

Renders an array or object as a sortable table in DevTools; the optional second argument restricts which columns are shown.

C#
var people = new[]
{
    new { Name = "Ada", Role = "Engineer" },
    new { Name = "Grace", Role = "Admiral" },
};

await console.Table(people);
await console.Table(people, new[] { "Name" }); // only the Name column
Live sample
tabular data output
Results will appear here when you interact with the samples.

Counters

Count / CountReset

Count logs how many times it has been called with a given label; CountReset sets that counter back to zero.

C#
await console.Count("clicks");      // clicks: 1
await console.Count("clicks");      // clicks: 2
await console.CountReset("clicks"); // back to 0
Live sample
counters output
Results will appear here when you interact with the samples.

Timers

Time / TimeLog / TimeEnd / TimeStamp

Start a named timer, log intermediate readings, and stop it to print the total elapsed time. TimeStamp additionally drops a marker into the browser's performance timeline.

C#
await console.Time("load");
await console.TimeLog("load");  // load: 102 ms
await console.TimeEnd("load");  // load: 341 ms - timer ended

await console.TimeStamp("checkpoint");
Live sample
timers output
Results will appear here when you interact with the samples.

Groups

Group / GroupCollapsed / GroupEnd

Indents subsequent output into nested, collapsible groups. GroupCollapsed starts the group closed; GroupEnd steps back out one level.

C#
await console.Log("Outer level");
await console.Group("Details");
await console.Log("Inside the group");
await console.GroupCollapsed("Collapsed by default");
await console.Log("Hidden until expanded");
await console.GroupEnd();
await console.GroupEnd();
Live sample
groups output
Results will appear here when you interact with the samples.

Trace & profiling

Trace / Profile / ProfileEnd

Trace prints the current stack trace. Profile and ProfileEnd start and stop the browser's built-in JavaScript profiler under an optional name.

C#
await console.Trace("How did we get here?");

await console.Profile("render");
// ... the work you want profiled ...
await console.ProfileEnd("render");
Live sample
trace output
Results will appear here when you interact with the samples.

Clear

Clear

Wipes the DevTools console (some browsers keep a 'Console was cleared' notice).

C#
await console.Clear();
Live sample
clear output
Results will appear here when you interact with the samples.
Note:
Open DevTools to see the results Everything on this page writes to the browser's own console. Press F12 (or Cmd+Option+I on macOS) and keep the Console tab visible while clicking the buttons; the output panel below only confirms each call was made.
Warning:
Profile is non-standard Profile and ProfileEnd are outside the console standard and behave differently across browsers - some require DevTools to be open, and support may change over time.

API reference

Member
Signature
Description
Assert
Task Assert(bool? condition, params object?[]? args)
Logs a message and stack trace if the condition is false.
Clear
Task Clear()
Clears the console.
Count
Task Count(string? label = null)
Logs the number of times this line has been called with the given label.
CountReset
Task CountReset(string? label = null)
Resets the value of the counter with the given label.
Debug
Task Debug(params object?[]? args)
Outputs a message to the console with the log level debug.
Dir
Task Dir(object? item, object? options = null)
Displays an interactive listing of the properties of the specified object.
Dirxml
Task Dirxml(params object?[]? args)
Displays an XML/HTML element representation of the specified object if possible.
Error
Task Error(params object?[]? args)
Outputs an error message.
Group
Task Group(params object?[]? args)
Creates a new inline group, indenting all following output by another level.
GroupCollapsed
Task GroupCollapsed(params object?[]? args)
Creates a new inline group that starts collapsed.
GroupEnd
Task GroupEnd()
Exits the current inline group.
Info
Task Info(params object?[]? args)
Informative logging of information.
Log
Task Log(params object?[]? args)
General output of logging information.
Profile
Task Profile(string? name = null)
Starts the browser's built-in profiler, optionally under a name.
ProfileEnd
Task ProfileEnd(string? name = null)
Stops the profiler; the resulting profile appears in the browser's performance tool.
Table
Task Table(object? data, object? properties = null)
Displays tabular data as a table; the optional second argument selects the columns.
Time
Task Time(string? label = null)
Starts a timer with the specified name; up to 10,000 timers can run per page.
TimeEnd
Task TimeEnd(string? label = null)
Stops the specified timer and logs the elapsed time in milliseconds.
TimeLog
Task TimeLog(string? label = null, params object?[]? args)
Logs the current value of the specified timer without stopping it.
TimeStamp
Task TimeStamp(string? label = null)
Adds a marker to the browser performance tool's timeline.
Trace
Task Trace(params object?[]? args)
Outputs a stack trace.
Warn
Task Warn(params object?[]? args)
Outputs a warning message.
An unhandled error has occurred. Reload 🗙