简体   繁体   中英

System.out To Android Logcat In Eclipse

I am working on an Android project with some classes that I plan to pull out as a pure Java.jar (to be used in other java related projects). In these pure Java classes, I use System.out to log. This is also an Android application though, so n my Android classes, I obviously use Log .

In monitoring the pure java classes, I can't get System.out to print out in my Eclipse logcat. I do see System.err though.

Does anyone know how to get System.out to display in LogCat in this fabled Log.i level?

Setup

  1. Nexus 7 - Android 4.4.4 - Stock
  2. Eclipse Kepler
  3. Android SDK 21
  4. Ubuntu 12.04 64 bit
  5. Monitoring all messages tab in Logcat, logcat set to verbose

I've Tried

adb root
adb shell start
adb shell setprop log.redirect-stdio true
adb shell stop
  • Logcat is set to verbose
  • Nothing in Console under Android or DDMS

Now you can send your Pure Java project logs into warning level for example...

    OutputStream os = new OutputStream() {

        @Override
        public synchronized void write(byte[] buffer, int offset, int len) {
            Log.w("blah", new String(buffer));
        }

        @Override
        public void write(int oneByte)
                throws IOException {
            // Not really sure what to do here...
        }
    };
    System.setOut(new PrintStream(os));
    System.out.println("Adam.");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM