什么是java的console.log()?

时间:2022-08-25 19:43:57

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

我正在构建一个Android应用程序,我想知道最好的方法是在javascript中调试console.log的最佳方法

2 个解决方案

#1


72  

The Log class:

Log类:

API for sending log output.

用于发送日志输出的API。

Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.

通常,使用Log.v()Log.d()Log.i()Log.w()和Log.e()方法。

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

详细程度的顺序,从最小到最多,是ERROR,WARN,INFO,DEBUG,VERBOSE。除非在开发期间,否则不应将详细编译到应用程序中。调试日志在运行时编译但被剥离。始终保留错误,警告和信息日志。

Outside of Android, System.out.println(String msg) is used.

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

#2


15  

Use the Android logging utility.

使用Android日志记录实用程序。

http://developer.android.com/reference/android/util/Log.html

http://developer.android.com/reference/android/util/Log.html

Log has a bunch of static methods for accessing the different log levels. The common thread is that they always accept at least a tag and a log message.

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

Tags are a way of filtering output in your log messages. You can use them to wade through the thousands of log messages you'll see and find the ones you're specifically looking for.

标记是一种过滤日志消息中输出的方法。您可以使用它们来浏览您将看到的数千条日志消息,并找到您专门寻找的消息。

You use the Log functions in Android by accessing the Log.x objects (where the x method is the log level). For example:

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

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:

你可以使用android的logcat工具看到你的日志消息:

adb logcat

Or by opening the eclipse Logcat view by going to the menu bar

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

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

#1


72  

The Log class:

Log类:

API for sending log output.

用于发送日志输出的API。

Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.

通常,使用Log.v()Log.d()Log.i()Log.w()和Log.e()方法。

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

详细程度的顺序,从最小到最多,是ERROR,WARN,INFO,DEBUG,VERBOSE。除非在开发期间,否则不应将详细编译到应用程序中。调试日志在运行时编译但被剥离。始终保留错误,警告和信息日志。

Outside of Android, System.out.println(String msg) is used.

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

#2


15  

Use the Android logging utility.

使用Android日志记录实用程序。

http://developer.android.com/reference/android/util/Log.html

http://developer.android.com/reference/android/util/Log.html

Log has a bunch of static methods for accessing the different log levels. The common thread is that they always accept at least a tag and a log message.

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

Tags are a way of filtering output in your log messages. You can use them to wade through the thousands of log messages you'll see and find the ones you're specifically looking for.

标记是一种过滤日志消息中输出的方法。您可以使用它们来浏览您将看到的数千条日志消息,并找到您专门寻找的消息。

You use the Log functions in Android by accessing the Log.x objects (where the x method is the log level). For example:

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

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:

你可以使用android的logcat工具看到你的日志消息:

adb logcat

Or by opening the eclipse Logcat view by going to the menu bar

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

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