How to do logging in React Native

Solution 1:

Use console.log, console.warn, etc.

As of React Native 0.29, you can simply run the following to see logs in the console:

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

Solution 2:

console.log works.

By default on iOS, it logs to the debug pane inside Xcode.

From the iOS simulator, press (+D) and press Remote JS Debugging. This will open a resource, http://localhost:8081/debugger-ui on localhost. From there, use the Chrome Developer tools JavaScript console to view console.log

Solution 3:

Pre React Native 0.29, run this in the console:

adb logcat *:S ReactNative:V ReactNativeJS:V

Post React Native 0.29, run:

react-native log-ios

or

react-native log-android

As Martin said in another answer.

This shows all console.log(), errors, notes, etc. and causes zero slow down.

Solution 4:

Use console.debug("text");

You will see the logs inside the terminal.

Steps:

  • Run the application:
react-native run-ios        # For iOS
react-native run-android    # For Android
  • Run the logger:
react-native log-ios        # For iOS
react-native log-android    # For Android