13

I'm starting with react-native and I'm getting this problem: I can't log to bundler metro server.

If I create my application using create-react-native-app, I can do 'console.log' and value are logged to metro bundler (running on port 8081).

But if I create my application with react-native init <project>, this doesn't work. To make console.log work, I need to open Chrome DevTools and set remote debug in application.

So my question is: is there any way to make native code to log in bundler console with console.log? I don't want to work with 'create-react-native-app' because it uses Expo and 'realm' database doesn't support expo.

I've tried with react-native 0.55.4 and 0.56, both in windows and linux.

1

5 Answers 5

22

You can also see the console.log() outputs using these commands:

$ react-native log-android
$ react-native log-ios

Note: It also works to debug native errors, for example when you have a blank screen and metro bundler doesn't show errors neither.

For more information you can check this out

Sign up to request clarification or add additional context in comments.

3 Comments

Command log-android unrecognized. Make sure that you have run npm install and that you are inside a react-native project. Kindly, could you explain me what's the problem?
Does not work for me, I only see generic React Native log messages, such as Initializing React Xplat Bridge..
It doesn't work for me. I'm i MacOS and I've installed react native with "npm install react-native", and the command "react-native log-android" show me some thing similar to Metro but it doesn't show the console.log output.
3

Don't know if I correctly understand your question (because of my english), but you can try this:

Run adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your Android app's logs.

Taken from Using adb logcat for React Native Debugging

Comments

1

You can download React Native Debugger and Open your JS Debugger in development menu. You can see everything into RN Debugger.

Comments

1

I discovered that console.log are omitted from console log if your disable remote debug from the debug menu

Comments

1

On Mac. While on ios simulator Clicked on

Command-d->Stop Debugging

.This made logging work for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.