24

Just getting started with Meteor, on Windows. Following the initial instructions, the automatically generated "Hello World" app is running on localhost. The text and button are there, but clicking it doesn't output anything to the console. However, replacing console.log() with alert() does show the text ("You pressed the button") in the pop-up window.

dimfisch
  • 437
  • 1
  • 4
  • 9
  • 1
    What browser are you using? – Rahul Jan 15 '13 at 20:47
  • 1
    Could you post the code you are working with? (It's a good idea to do when you ask a question related to some code you are working with) – knownasilya Jan 15 '13 at 21:07
  • 2
    Are you putting `console.log` inside a `Meteor.isServer` block? If so, it will render in the terminal from which you ran `meteor` to start your project, not the browser console. – TimDog Jan 15 '13 at 21:09
  • @Rahul Chrome v24 @Knownasilya First time I ask a question on Stackoverflow :) Here you go: `if (Meteor.isClient) { Template.hello.greeting = function () { return "Welcome to patio."; } Template.hello.events({ 'click input' : function () { // template data, if any, is available in 'this' if (typeof console !== 'undefined') alert("You pressed the button"); } }); }` @TimDog I guess that's it. It's in a `Meteor.isClient` block. – dimfisch Jan 15 '13 at 22:35

6 Answers6

22

the console.log() output is printed in the browser. but it gets cleared immediately if you are submitting a form or handling an event as the page automatically gets refreshed.

if you want it to work, 1.Use chrome browser 2. check "Preserve log" check box on the console. then you can see the log

Ajay Kumar
  • 336
  • 2
  • 2
8

@dimfisch - I didn't see a console.log in your code snippet above. At any rate, I'm reiterating my comment as an answer:

Any console.log entries that are inside a Meteor.isServer block will by default NOT show up in the browser's console log. They'll show in the terminal from where you launched your app via the meteor command.

TimDog
  • 8,758
  • 5
  • 41
  • 50
  • Yes, that's because I replaced `console.log` with `alert` in the code. And since it's in a `Meteor.isClient` block I'm not seeing it in the terminal window. Thanks. – dimfisch Jan 16 '13 at 01:48
8

For anyone coming by here and currently losing your mind: for me I had searched using the Filter textbox at the top of the console. If you forget to clear that, you wont see any of your logs that don't match the filter :)

1

Make sure you are looking at the right console. It might be your console is not logging the page you are testing. :) Happened to me.

jiv-e
  • 483
  • 6
  • 8
0

On the console, the left of any console.log() you write to the console, there are a sidebar with several tabs: eg. 5 messages, 2 user messages, 4 errors, 1 warning, No info, No verbose etc.

I find myself this morning not selecting the '5 user messages' item on the left panel. Instead, I have selected the 'No errors' item accidently. So I don't see any console.log() there. That can be one of the reasons.

Mr Chan
  • 47
  • 7
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 16 '21 at 04:14
-1

In the console sidebar, open the "X Info" tab where "X" is the number of messages or something.

Alex
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 22 '21 at 18:09