APP nodejs: prevent logs in terminal window

Asked

Viewed 85 times

0

I created an application in Nodejs with Express and when I put this application to run (with npm start), There are some logs appearing in the terminal window where I am connected to each page that I access from my routes. Is it supposed to be that way? It can be disabled and it better be disabled?

logs in the terminal window:

GET /javascripts/jquery/jquery-ui.js 304 32.627 ms - -
GET /javascripts/jquery/datepicker-pt-BR.js 304 32.307 ms - -
GET /javascripts/chartjs/Chart.js 304 32.109 ms - -

1 answer

0

You can use the following line of code:

console.log = function(){}

Any call to console.log will be "ignored" from that point

If you want to enable/disable, you can assign console.log a variable to then recover

Ex.:

var log = console.log;
console.log = function(){};//Desativa
console.log = log;//Ativa novamente
  • thanks for the feedback. But I would like to know if what causes these logs on the screen is to continue like this. If not to continue like this, this way you indicated is only way? or there is some feature enabled by default in the basic project structure that Express creates, which keeps generating these logs, and which can be disabled?

  • I don’t know much about nodejs, but I think there are no problems with the log, this option I passed is generic in javascript

  • 1

    Okay, thanks for the feedback

Browser other questions tagged

You are not signed in. Login or sign up in order to post.