4

I am planning on signing an apk and releasing it (through Export Eclipse tool). Then upload it to the market. I know that debuggable is set to false by default when signing it so that means that no logs will be captured. At the same time, if I set debuggable to true and release the apk then I will get all the logs.

What I am really interested in is the last debug statement that are added by me only. Currently, I am using the Log.i statement to add info logs. Is there a way to have my app logging only the Info logs (i.e. my logs only). Mybe if I disable the log and have system.out.print it would work?

The reason I am doing this is becuase I want to send the last 100 lines of log when a crash happens and I am only interested in my log statments.

Please help me out Thanks

Snake
  • 14,228
  • 27
  • 117
  • 250
  • I think [this answer](http://stackoverflow.com/questions/5553146/disable-logcat-output-completely-in-release-android-app) is the closest you will get. – Cat Aug 22 '12 at 17:07

3 Answers3

1

You will have to put a wrapper on top of Log where you can put functionality to control the log levels.

Chitranshu Asthana
  • 1,089
  • 8
  • 19
  • How would this work? If I understand you correctly, wouldn't that involve modifying the Android source? Because if `Log` is wrapped within the app itself, other apps (and the OS) would still use the Android system's `Log`, which is unwrapped. – Cat Aug 22 '12 at 17:06
  • read you question again and understood that you want to capture state of application when it crashed. To do this, you can create custom logger which will write into a file which can be uploaded t server. Custom logger will give you full control over size and log level of logs you want to capture. Hope this will answer your question. – Chitranshu Asthana Aug 22 '12 at 17:11
  • Hmm. This makes sense actually ( By the way I am the one who posted the question :) ). I like your suggestion, the only problem is that I use ACRA to send me the logs. How can I use it to send the customzied log file? Otherwise I would have to write my own code to send it which is becoming too much – Snake Aug 22 '12 at 17:42
1

This type of functionality is already implemented by the ACRA Android library. The library detects crashes, and send the crash information to either a Google Docs spreadsheet, or your own destination. You can add additional information like the past 100 lines of your log using the method shown here.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
  • Yes I use ACRA to send me the last 100 lines already. The problem is that the 100 lines are made up by all the system logs. I need the last 100 lines of "my logs" which is not functionality in ACRA – Snake Aug 22 '12 at 17:39
  • You can use the logcat arguments from the second link to filter logs to only your Process ID, or only one TAG. That way, only your apps messages will come – Raghav Sood Aug 22 '12 at 17:48
  • Yes, when you do the filtering then what happens ACRA will take the last 100 lines of system logs, filter it based on your TAG and send you the filtered version (which ends up being 10-20 lines). I would need to use argument of 1000 to accomplish what I want but ACRA says not do that as it is too much. I have asked the questiona but it in http://stackoverflow.com/questions/11946581/logcat-filtering-and-number-of-lines and I still didnt get an asnwer – Snake Aug 22 '12 at 17:52
1

I believe what you need to do is take advantage of ACRA's built in filtering functionality:

In the Advanced Usage wiki you can see that you can set your logcat arguments in your config.

In your logging, tag your custom log messages with a specific tag and debug level, then in the logcat arguments, then set a parameter:

logcatArguments = { "-t", "100", "-v", "long", "ActivityManager:I", "MyApp:D", "*:S" }

add one in the form of

"YourCustomTag:<YOUR_DEBUG_LEVEL>" 

and take out the ones you don't want to be logged (probably MyApp:D in this case.)

D Yao.
  • 391
  • 1
  • 6
  • Yes, when you do the filtering then what happens ACRA will take the last 100 lines of system logs, filter it based on your TAG and send you the filtered version (which ends up being 10-20 lines). I would need to use argument of 1000 to accomplish what I want but ACRA says not do that as it is too much. I have asked the questiona but it in stackoverflow.com/questions/11946581/… and I still didnt get an asnwer – Snake Aug 22 '12 at 18:33
  • Ah I see what you're saying. To be honest, the best solution then maybe to move away from acra and use your own kind of error logging: something along the lines of this answer: http://stackoverflow.com/a/755151/1359772 – D Yao. Aug 22 '12 at 18:36