question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable console logging to the terminal

See original GitHub issue

In the new version of react-native-cli, the console.log output is forwarded to the terminal when react-native start is used.

While there are many situations when this is very convenient and helps with debugging, I would like to know if there is a way to disable it: I have created a custom logger for all network calls, that leverages console.log styling options to provide a nice reading experience for large objects. The styling doesn’t work in the terminal, so I end up with huge unreadable blobs of data that are only making a mess in my terminal.

Is there a way to disable terminal logging, so I can keep debugging in the chrome console while also keeping my terminal as clean as possible?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:18
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
bathancommented, Nov 8, 2019

Would love to be able to toggle this on/off with a config.

Having all logs going to metro has some big impact on overall app performance when debugging.

This week I spent some decent amount of time debugging some performance issue that was affecting a screen where we have a tiny images list and we also use that screen to upload images to a server.

I could not find what was the cause for that whole screen suddenly being terribly slow and unresponsive. When I suddenly noticed this on a terminal window:

ezgif com-optimize

At first, I was feeling a little bit like Tank in Matrix, but then I remembered:

This screen had a simple console.log for the images array list and each item had the base64 data property for the images and they were between 4 and 8 MB worth of text each.

When all that text was being sent to the console, it eventually eats up all the console buffer and everything started slowing down. Hitting CMD + K (Clear terminal) like crazy while that was happening was the only way to prevent the performance hit. Removing the console.log did the permanent trick but we have lots of scenarios like this where we console.log if we are in DEV environment and it has been a real problem having to go and prune those out because of the performance hit we were having.

As @hayanisaid we also have a huge redux state tree and its also partially being logged for debugging and it was killing us.

Now I’m currently running yarn start > /dev/null to prevent anything from being outputted on console and it runs smoothly again and I can keep my logs.

1reaction
hayanisaidcommented, Nov 5, 2019

I have to the same problem, and it’s really annoying cuz I’m using redux and the redux logger print all the data store into the console the things that make my terminal crashes

Read more comments on GitHub >

github_iconTop Results From Across the Web

logging - how to stop console logging - Cisco Community
I want to stop them completely when I am doing work. But not turn off logging to my syslog server. Solved! Go to...
Read more >
Disable console logging « ipSpace.net blog
To stop the console logging, use the no logging console global ... a terminal) is attached to it; if console logging is enabled, ......
Read more >
How to quickly and conveniently disable all console.log ...
How to use the above 'logger'? In your ready event, call logger.disableLogger so that console messages are not logged. Add calls to logger....
Read more >
B.1. Disable logging to console
B.1. Disable logging to console. Before attempting to upload or download files it is a good idea to prevent messages from appearing on...
Read more >
How to Disable Console Logging in Spring Boot - Baeldung
Learn how to configure a Spring Boot application so that it does not log to the console, whether it is using Logback, Log4j2, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found