Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 905
Arvin Avatar asked Oct 21 '12 11:10

Arvin


People also ask

Can you console log in JavaScript?

The console. log() is a function in JavaScript which is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user. Syntax: console.

How do I add a console to Visual Studio?

Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.


1 Answers

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.

like image 139
ThiefMaster Avatar answered Sep 23 '22 22:09

ThiefMaster