Arvin Arvin - 7 months ago 30
Javascript Question

console.log() in windows 8 javascript/visual studio 2012

When I use console.log("Some text output") in javascript in Visual Studio 2012 for Windows 8 metro programming where is the text being sent to? Where can I view it? I've got the "Output" panel up but I do not see the log text.

Am I not using the right function? Is there another function I must use to print to Output?


To actually see the JavaScript console select DEBUG > Windows > JavaScript Console in the Visual Studio menus. Then you can use the good old console.log() to write to it, but you can also use the related WinJS functions:

There is WinJS.log() to log something after creating the function with WinJS.Utilities.startLog():

WinJS.Utilities.startLog({type: "info", tags: "custom" });
WinJS.log("my message", "info", "custom");

Here's some additional information on the WinJS logging functions:

startLog(options): Configures a logger that writes messages containing the specified tags to the JavaScript console.

The options object must contain a type which is supposed to be one of error, warn, info or perf. Unless you want to capture all log entries, also add tags to the object containing a space-separated list of tags you want to be logged.

WinJS.log(message, tags, type): This function does not exist by default. However, it is created by your startLog() call. You could also create it manually but since you want logging to the console using startLog() is the way to go.