Android: sharing a powerful LOG switch --- Log. isLoggable, log. isloggable
1. API highlights:
This API can be implemented without changing the APK, and the effective log can be directly captured on the problematic mobile phone, which can improve the work efficiency.
2. API Introduction
Recently, when solving text message problems, we saw a very powerful LOG switch-Log. isLoggable
1.If(Log. isLoggable (LogTag. TRANSACTION, Log. VERBOSE )){
2. Log. v (TAG, "Creating TransactionService ");
3 .}
Go to the framework to view the definition of the isLoggable method, and find that this is a JNI method. However, there are many annotations on the method declaration. I read it carefully and found that this is a gift from android.
Check whether the current tag is at the specified log level. Generally, the default log level is INFO, which means that all logs including INFO will be output. You can modify the default log level by setting system properties and execute the following command:
1. setprop log. tag.; YOUR_LOG_TAG>; LEVEL
You can also write this code into the local. prop file and put it in/data/local. prop. According to the above instructions, try to execute the following command:
1. adb shell setprop log. tag. Mms: transaction VERBOSE
Then I sent a MMS test, and all the valid logs were output.
We are doing some mining on this basis to see what surprises google has given us. From the LogTag. TRANSACTION in the second code above, we can see that there is a LogTag. java file in the Mms package, and many constants are declared in it:
1.Public static finalString TRANSACTION = "Mms: transaction ";
2.Public static finalString APP = "Mms: app ";
3.Public static finalString THREAD_CACHE = "Mms: threadcache ";
4.Public static finalString THUMBNAIL_CACHE = "Mms: thumbnailcache ";
5.Public static finalString PDU_CACHE = "Mms: pducache ";
6.Public static finalString WIDGET = "Mms: widget ";
7.Public static finalString CONTACT = "Mms: contact ";
These are all important log switches in MMs. After knowing this, it will be much easier to debug the mms. without changing the APK, you can directly capture the valid log on the problematic mobile phone, which can improve the work efficiency. Let's load it back and see where isLoggable (Stringtag, int level) is called. Besides the framework layer and Mms application, it is found that important modules such as Contacts are called, it will be much easier to debug these modules in the future.
How can android log output the value of a long integer variable to logcat?
Long var;
Log. v (TAG, "" + var );
For the log error information of the android program, I am a beginner. I have not changed a new android project.
Exception in thread "main" java. lang. SecurityException: unable to locate logon Configuration
At com. sun. security. auth. login. ConfigFile. <init> (ConfigFile. java: 97)
He said he couldn't find the file. You can see if the path is incorrect elsewhere,
Your questions and answers are not clear enough. You may have to guess this and it is very difficult to solve!
You should give some code or take a look at the resource file and xml next time!