Why is redirecting stdout/stderr on android not working?

Solution 1:

According to this presentation, log.redirect-stdio is for Dalvik output, to redirect C/C++ output (such as printf), you must install busybox on the device and use its xargs utility like this:

myprogram | xargs log

This obviously works for code that gets called as a standalone executable. If it's only for debugging purposes, you can write a tiny program to call your library and call that from your application using xargs.

Solution 2:

Another way of doing this is having a file /data/local.prop, containing just the line log.redirect-stdio=true. Maybe this works better? Also, note that stdout is buffered, so it could be that your output is still sitting in the buffer, waiting to be flushed. You can call fflush manually to check this.