How to use console.log()

Reposting in Development Section

Hello,

I am modifying room.js in this location:
./app/ui/client/views/app/room.js

Please note that I am modifying rocketchat 3.10.0, which is a version of rocketchat which used meteor.

I am having trouble running a simple:
console.log(“hello”);

However, this command is running fine in the same script:
Template.room.events({
“click #payNow”: function () {
FlowRouter.go(/payNow);
},
});

Why might console.log not work? It seems like there may be some setting on the backend of rocketchat which is stopping anything from logging to my console, as I have tested this with another meteor project and it works totally fine.

Does anyone have any suggestions? Even a workaround would be great.

Much appreciated,

Gavin

Server Setup Information

  • Version of Rocket.Chat Server: 3.10.0
  • Operating System: OSx
  • Deployment Method: Meteor
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 12.18.4 - x64 |
  • MongoDB Version: 4.2.8 |
  • Proxy: None
  • Firewalls involved: None

Hi! Welcome back :slight_smile:

You should always avoid changing Rocket.Chat core code. have you evaluated if you can create, instead, a Rocket.Chat App?

regarding your question, the console.log, as it’s running on client, should be shown in the browser, not in the server logs.

Also, try using the proper logging mechanisms, instead of pure console.log. After some version, all logs became json (for the sake of easier log monitoring).

let me know if this helps :slight_smile:

Thank you duda!

I have been trying to modify a few things about rocket.chat, and I did not know that the logs became JSON. Even when I console.log data from the client, it does not appear in the browser, so I assume that it is also being logged as JSON.

Do you know where I can find the JSON file with the logs? If you don’t know the specific location of the JSON file, do you know what the file is called so I can search for it within my Rocket.Chat application?

Also, I will take your advice of evaluating whether or not I could make a Rocket Chat App. I am going to follow this guide as a tutorial. :slight_smile: Creating Your First App - Rocket.Chat Developer

Thanks,

Gavin

hi @gwkerr !

We just had a nice Hackathon here at Rocket.Chat, and we produced some nice contents about App and Bot development with Rocket.Chat.

Check it out:

The server logs are usually printed out at stdout, while client will go to browser.

if you are using snaps, here is a page where you can get to know more about logs on this kind of deployment:

if using docker, docker compose logs -f --tal 10 will do the trick