How to receive logcat (esp. VrApi) messages in-game?

I’m working on a Meta Quest (which is an Android device) game, and I’ve just learned about all the really handy things that the system spews to the console, like these VrApi stats. I know how to get these on my Mac with logcat (and filter with -s), but I’d really like to have them in-game.

Is there any way for my Unity app to receive logcat messages (or some subset of them, like just the VrApi messages) at runtime?

Check this out https://stackoverflow.com/questions/12692103/read-logcat-programmatically-within-application

I guess the trick would be to read those in Java and then send the text to your C# scripts

Hmm. Many of the approaches in that SO article are simple running logcat as a subprocess with exec. I wonder if we could do the same thing using System.Diagnostics.Process?

This is something you’ll need to try, I am not entirely sure if Unity’s il2cpp .NET implementation allows spawning processes on Android.

1 Like