Search code examples
javaloggingandroid-sourcejava.util.logging

logging inside libcore in aosp


I try to log inside libcore of aosp, eveytime when ScheduledThreadPool is create. So I add logging inside luni/src/main/java/java/util/concurrent/ScheduledThreadPoolExecutor.java

    import java.util.logging.*;

after I call

    private static final Logger logger = Logger.getLogger(ScheduledThreadPoolExecutor.class.getName());

and try to log massage, but I didn't get it anywhere, I guess it in the application console inside JVM. I try to create FileHandler and the FileHandler return null for me, I try to log to logcat using ConsoleHandle and change the log level to FINE and I didn't succeeded. I try also to read the configuration file from luni/src/main/java/java/util/logging using LogManager.readConfiguration(InputStream) and still I get null pointer to this file when I try to read it relative (I try path "/logging.properties" and "../logging/logging.properties").

The most clean solution is use the configuration file, but every solution that work can be fine. My question is how I can log and get the log massage in libcore (it can be in file or in logcat or to socket).

Thanks alot.


Solution

  • I find a good way to write to logcat, I saw in luni/src/test/java/tests/support/ThreadPool.java use of Logger.global.info() so I tried to use it in my code, and surprise, it is seen in logcat as "I global :"