How to hide all my logs when users use my android app? - android

My boss hopes that there is no information leak when users use our android apps.
And I found even I set the android:debuggable="false" it still can see my logs from Logcat or command line.
I searched android:debuggable someone also have the same problem.
I got some answers from internet, such as next:
There are a property called debugable of Avd. You can print by adb
shell get prop. I don't (know) if it is the cause of your problem.
If you have a pre-production device, you
can still debug an app that has debuggable set to false.
I just think, even I delete all my logs, there are also many logs about my app from OS.
My questions:
1.Is there a way I can do let my "android:debuggable" work well and
2.Is there any other way to hide all my logs except delete all my logs?
3.What does "android:debuggable" really mean?
4.What is "a pre-production device" when it goes on android device?
Thank you for your help. I will try some other ways, and try my best to share my information in here.

I simply create wrapper functions around Log that first check the value of a static boolean called loggineEnabled if it is set to true then log gets called otherwise the calls to log are ignored.
Then I simply set this variable to false before I compile a version of my app that I distribute.
void LogD(String msg){
if (loggingEnabled)
Log.d(MyTag, msg)
}

Is your code guaranteed to be bug-free? If not, why do you want to stop users having information that they might be able to use to shed light on bugs in your app?
Come back when you can write bug-free code, then we’ll talk.

Related

Android : How to enable logging Log.v values which are by default disabled

I am a novice to the Android Studio and working on one group project.I am trying to log some variable values to logging.
When I use Log.e values are properly logged. While when I use Log.w or Log.v nothing gets printed. Here I am switching from logcat from error to verbose and to warning as I am using Log but still can't see anything printed.I previously used Toast but heard that using it might make my app slow and using Log.e everywhere is not a good practice.So how to print logs of lower priority?
I tried referring following resources but didn't find anything that could help me enabling logging for lower priority Logs, Just got the info that for some reason lower priority logs are disabled.
https://developer.android.com/reference/android/util/Log.html
Android Log.v(), Log.d(), Log.i(), Log.w(), Log.e() - When to use each one?
Thank you in advance.
All logs are always default enabled.
I think you are viewing logs in error view.
Check
You are viewing logs in Verbose
Your filter is set to selected app.
You have selected your app not other app. (where in below image no debuggable process is written)
Android Log.v(), Log.d(), Log.i(), Log.w(), Log.e() - When to use each one?
Log.e: This is for when bad stuff happens. Use this tag in places like inside a catch statement. You know that an error has occurred and therefore you're logging an error.
Log.w: Use this when you suspect something shady is going on. You may not be completely in full on error mode, but maybe you recovered from some unexpected behavior. Basically, use this to log stuff you didn't expect to happen but isn't necessarily an error. Kind of like a "hey, this happened, and it's weird, we should look into it."
Log.i: Use this to post useful information to the log. For example: that you have successfully connected to a server. Basically use it to report successes.
Log.d: Use this for debugging purposes. If you want to print out a bunch of messages so you can log the exact flow of your program, use this. If you want to keep a log of variable values, use this.
Log.v: Use this when you want to go absolutely nuts with your logging. If for some reason you've decided to log every little thing in a particular part of your app, use the Log.v tag.
Explanation by link Kurtis Nusbaum
Update:
If above things does not work then you are facing an device setting issue. Some mobiles have set default log level to DEBUG or ERROR. Allow logging from phone setting.
You can check if log is loggable by Log.isLoggable()
Check
Settings -> Accessibility -> Developer options -> advanced logging->set "Allow all"
or
Settings->Accessibility - > Developer Options -> Performance optimization -> Advanced logging -> set "Allow all"
or for other phone search in "developers options": option "logging" and set "all".
also you can use Log.wtf when your Log.d is not working.
try restarting android studio also

LogCat won't show my logs

I've searched for similar problems, but I didn't find anything useful - I'm working with eclipse, and I can't see my Logs.
The device is connected properly, the app runs and does what it's supposed to do, but I get no logs from it.
I get other logs messages from the device, not the ones that I print, e.g. Log.d("SMS", "hello"). On the other hand, if I use the statement System.out.println("hello"), I do see it, tagged as System.out.
I've tried to disconnect and reconnect the device, restart it, close and open eclipse, choose the device from Device window. It happens both with a 'real' device and an emulator. I've also tried to remove the filtering, but nothing helps - I still don't get the logs.
Okay, I've found the problem -
Apprently there are some illegal tags, and I've used one of them.
My app is spam SMS blocker, and I've used the tag SMS. If I change it to another tag (like SMSBlocker) it suddenly appears in the LogCat.
Check if your project is using proguard.
Basically proguard will remove all the debug logs and optimize your code while creating apk.
Try adding proguard.enabled=false in your project.properties
I think you should use TAG.
When you log from your android app, the first parameter is a TAG string. So if you set it up to a unique string (like your app name) then you can later filter by it in Eclipse.
Example : Log.e(TAG, "state error");

Using Android Studio's logcat better, permanent focus on a single process?

When testing on a device in Android Studio you get an awful lot of output in the logcat.
I'm only interested in the output for the app I'm developing. I can see just this, after running, by opening the Devices section and manually selecting my apps process. Problem is, it's pretty tedious to do this every time I run my app, which seems to be the case.
Is there a way to get it to remember this setup?
How about a way to get it to stop reporting anything after I'm done with my app or it's crashed ? (otherwise my app specific stuff gets buried so quickly by output from other proccesses on my phone)
I'm open to other ways of filtering the logcat too, however I couldn't think of a way to set up filters so that I would get my tagged Log messages AND other exceptions I wasn't expecting.
Any suggestions?
Normally this is done by default, but if not,
in logcat, the green plus sign, when you click it you get a dialog, fill the byApplicationName with your package name, and also your filter name with something, now you can filter your output according to your app
with that beeing said, sometimes you don't get the filter column info (application name) in logcat at all (blank), here (and I my self don't know the cause of it) just forget it for a while and retry again

Disable log related to other application/system - android

I am using HTC One X.
There are some system application that has too many logs.
Because of that, I am able to see my application log only for some seconds. After some time, my logs are being remove from buffer since too many new logs from other application.
Can i disable log by using the tag.
Firstly, you cannot stop other applications from logging! Probably some apps more than others log too extensively causing an overflow. What you could try to do is
Force stop some apps so that thier logging activity is reduced(less chance it might reduce).
Secondly, as Rasel suggets,
Use DDMS features like filtering logs using application name, package name, TAG's etc. and pause logging.
In this way you will get a snapshot of your logs. Hope this helps!

Why are Log.d() messages showing on device when they shouldn't?

Android docs indicate:
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.
But try to do a Log.d() and you'll find it's actually still recording to Logcat on a real device.
Does anyone know why? Or how to disable it?
Thank you!
What you are seeing is expected behaviour. Log.d will always be logged and visible if you use logcat and connect the device. Hence if you dont want debug logs in production app , turn it off. Infact android sdk suggests you do that. This SO answer might help you as well. Should I comment my log calls when creating my final package?
Andriod sdk says
Turn off logging and debugging
Make sure you deactivate logging and disable the debugging option
before you build your application for release. You can deactivate
logging by removing calls to Log methods in your source files. You can
disable debugging by removing the android:debuggable attribute from
the tag in your manifest file, or by setting the
android:debuggable attribute to false in your manifest file. Also,
remove any log files or static test files that were created in your
project.
Also, you should remove all Debug tracing calls that you added to your
code, such as startMethodTracing() and stopMethodTracing() method
calls.
Source
You should encapsulate logging in your own class and enable/disable special types of logs when you need.
if verbose is compiled in dvelopment, it would be funny if debug logs not. So signe your app and give it a try, i think the debug messages are missing then.
When you plug your device it activates the debug mode. I don't think it's doing the same if the app run with the device unplugged, though you can not check that...

Categories

Resources