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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With