最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

console.log() in windows 8 javascriptvisual studio 2012 - Stack Overflow

programmeradmin3浏览0评论

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?

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?

Share Improve this question asked Oct 21, 2012 at 11:18 ArvinArvin 1,4315 gold badges20 silver badges34 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 16

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 need to debug the application in a live environment, you can use a simple on-screen console.log replacement, which you can activate using the ~ key.

Source code here: https://gist.github.com/4012355

You can also view the log through the EventViewer. Here are the steps to enable this:

Open Event Viewer
Navigate to Application and Services Log
Expand Microsoft/Windows/AppHost
Left click to select Admin
Right click Admin and then select View => Show Analytic and Debug Logs

I might be replying to an old post, or maybe you have discovered your way to serve your purpose, but I tried console.log() and WinJS.log() and the javascript console seem to return 'undefined' for both. Also, I made sure with 'debugger;' statement that that code was is executing. Now I am assuming here that you need logging for debugging purposes then what I would prefer to "print" to my screen now is:

<body>
  <label id="lblMessage">test</label>
</body>

and then in JS :

function f(message) {
  document.getElementById('lblMessage').innerText = message;
}

( and then, place a call to this function where needed - in my case it was, app.onactivated function)

发布评论

评论列表(0)

  1. 暂无评论