androidreact-nativeloggingreact-native-native-module

How to display logs from Android's native modules to react native's metro


I use the command npx react-native start to run the Metro of react native, I just use console.log() on my javascript files to log the data to that metro

The problem is when I'm trying to log from my native's android modules, It's not displaying on the metro,

I used Log.d and System.out.print() but still, I'm not getting the datas

@ReactMethod
public void testMe(Promise promise){
    Log.d("Test", "Test datas");
    System.out.print("Test");
    promise.resolve("success");
}

I also use npx react-native log-android but it's still not showing there.

Is there a way to log from the android's native module without sending the data to the react native?

PS: I'm also trying to log objects such as HashMap if possible.


Solution

  • While metro is running, Android Native Module logs are visible in Android Studio's Logcat. https://developer.android.com/studio/debug/am-logcat