2

I've been looking at my log recently for more development of android applications, and I've noticed my log is spammed with all sorts of information that I wouldn't considered needed to be logged.

Over time, I've notice my phone get slower. I've even noticed at this point, completely stock firmware with a number of apps from the Play Store, running music right now, and Eclipse can't even keep up with the log output on Verbose logging.

My question is related to this. Are the logs stored for a while that might cause space to gradually disappear? Is there a way to turn off some logging features as to not record to "disk" things like verbose, when apps don't even need it? I've always thought logging should be done if it's an error, not "just because". If it's debugging information, then the release version shouldn't log that much output (easily done with a simple variable switch). Am I wrong in this thinking?

Thanks in advanced!

  • I'm also interested in resources that might explain some "Best Practices" when dealing with logging. I don't want to log so much data that it slows down the app/system, but still want it to be useful if someone were to experience a crash. – Demortes Mar 11 '14 at 17:32
1

Android logs are stored in an internal ring buffer. As such, I don't see how even the overly verbose apps could slow the system down purely through logging.

  • Perhaps if you could expand on that? I've looked through it, it looks like it just gets random data and assembles it and spits it out coherently. Is there a log file generated, like the syslog of linux machines? – Demortes Mar 11 '14 at 20:49
  • A ring buffer is a way of storing data so that it doesn't grow beyond a certain size. Once you have more than X bytes/lines/whatever it overwrites older data with newer. – Hounshell Aug 11 '14 at 18:07
1

If the logs are really bothering you, you can deal with it two ways.

Options one is to turn them off. You can do this with

adb shell setprop log.tag.BadTag ERROR

That will only log them if it's error or higher, but you'll have to kill the application before it'll listen.

The second option is to use logcat directly and filter out what you don't care about. I have a logcat script that looks like this:

hounshell@hounshell:/home/hounshell/scripts$ cat logcat 
#!/bin/bash

for arg; do
    if [[ "$arg" == *:* ]]; then
        args="$args $arg "
    else
        args="$args $arg:* "
    fi
done

exec adb logcat \
  dalvikvm:W \
  ActivityManager:W \
  AndroidRuntime:W \
  ${args[@]} \
  *:S

This will only log stuff that I generally actually care about. You call it like ./logcat MyTag0 MyTag1:W MyTag2 MyTag3:D This will log everything for tags MyTag0 and MyTag2, warnings from MyTag1, and debugging from MyTag3. The downside here is that it's not directly in Eclipse (I personally consider that an upside, but I digress).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.