What's the console.log() of java?

I'm working on building an Android app and I'm wondering what the best approach is to debugging like that of console.log in javascript

296143 次浏览

The 木头 class:

用于发送日志输出的 API。

一般来说,使用 Log.v() Log.d() Log.i() Log.w()Log.e() 方法。

The order in terms of verbosity, from least to most is ERROR, WARN, 冗长绝不应该被编译成一个 除了在开发期间。调试日志编译在但 stripped at runtime. Error, warning and info logs are always kept.

在 Android 之外,使用 System.out.println(String msg)

使用 Android 日志记录工具。

Http://developer.android.com/reference/android/util/log.html

日志有许多用于访问不同日志级别的静态方法。公共线程是它们总是至少接受一个标记和一个日志消息。

标记是筛选日志消息中输出的一种方法。您可以使用它们来浏览您将看到的成千上万条日志消息,并找到您特别需要的那些。

通过访问 Log.x 对象(其中 x 方法是日志级别) ,可以使用 Android 中的 Log 函数。例如:

Log.d("MyTagGoesHere", "This is my log message at the debug level here");
Log.e("MyTagGoesHere", "This is my log message at the error level here");

I usually make it a point to make the tag my class name so I know where the log message was generated too. Saves a lot of time later on in the game.

You can see your log messages using the logcat tool for android:

adb logcat

或者通过转到菜单栏打开 eclipseLogcat 视图

Window->Show View->Other then select the Android menu and the LogCat view

Java 中的 console.log()System.out.println();,用于将文本放在下一行

System.out.print();将文本放在同一行中。

public class Console {


public static void Log(Object obj){
System.out.println(obj);
}
}


调用并作为 JavaScript 使用,只需这样做:

Console.Log (Object)

I think that's what you mean