[英]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). 我正在一个Android项目中工作,我计划将一些类作为纯Java.jar提取(用于其他与Java相关的项目中)。 In these pure Java classes, I use System.out
to log. 在这些纯Java类中,我使用System.out
进行记录。 This is also an Android application though, so n my Android classes, I obviously use Log
. 不过,这也是一个Android应用程序,因此在我的Android类中,我显然使用Log
。
In monitoring the pure java classes, I can't get System.out
to print out in my Eclipse logcat. 在监视纯Java类时,我无法让System.out
在我的Eclipse logcat中打印出来。 I do see System.err
though. 我确实看到了System.err
。
Does anyone know how to get System.out
to display in LogCat in this fabled Log.i
level? 有谁知道如何使System.out
在此寓言的Log.i
级别显示在LogCat中?
Setup 设定
I've Tried 我试过了
adb root
adb shell start
adb shell setprop log.redirect-stdio true
adb shell stop
Now you can send your Pure Java project logs into warning level for example... 现在,您可以将您的Pure Java项目日志发送到警告级别,例如...
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.");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.