What I am going to described has been tested with a 2.3 and a 4.4.2 devices, having exactly the same behaviour, so I isolated any potential issue coming from the change in access rights to LogCat.
I am using ACRA version 0.4.5
What I would like to do is very simple, make sure that I can send to the ACRA report at Cloudant the Logcat of the device filtered by my application name.
In order to perform this I followed the manual and some previous posts in SO (like this one: How to filter logcat output in ACRA?)
Ideally I should include in the configuration the following input:
logcatArguments = { "-t", "100", "MyApp:D", "*:S" }
However, this is not working properly and no error report arrives to the database, only 2 lines appear with an empty report. In order to ensure that there are logs I forced a LogCat output just before the forced calling, something like this:
Log.i(TAG + ":Sending Error or Suggestion", "My message ");
ACRA.getErrorReporter().handleException(null);
If I change (both devices) any of the following lines at the ACRA configuration:
logcatArguments = { "-t", "100", "MyApp:D"}
logcatArguments = { "-t", "100"}
I am getting the full report from LogCat without any filtering. I also tried including the -v long option (just in case).
Reviewing all answers in SO about this topic I found all of them outdated as I have not been able to explicitly find one related to this problem and the version 0.4.5.
Any idea what's happening?
======
CLARIFICATION
After some investigation the problem is not so simple.
Currently all documentation available provides example of how to filter in ACRA using TAGs and at the moment is not clear how to filter by Application as in Eclipse.
So if you are experiencing the same error as me probably will be due because (as the answer provided to this question suggests) you are not using exactly the same TAGs in all your Logs.
ACRA just provides those arguments directly to logcat. So you question is really, how do I filter logcat.
The logcat filters are everything after the params.
Filter are of the form <tag>:<log_level>.
If you specify a log_level of S then you are marking those messages as silent, ie don't show them.
So in the config in which you are getting no messages:
logcatArguments = { "-t", "100", "MyApp:D", "*:S" }
You are asking for all message logged with tag MyApp and to ignore all other messages. Since you are getting no log I would suggest that you have not actually used MyApp as a log tag within your app.
Related
anybody can explain if it's possible to attach a variable to the proguard crash reports??
I mean something like this:
java.lang.NullPointerException:
at es.com.myapp.dashboardActivity$askForUserBills.doInBackground (dashboardActivity.java) or .onPostExecute (dashboardActivity.java)
at es.com.myapp.dashboardActivity$askForUserBills.onPostExecute (dashboardActivity.java)
at android.os.AsyncTask.finish (AsyncTask.java:660))
**Application Variables: userID="967234112", myJsonObject=null << Something like this...**
In this example I requested "userID" and "myJsonObject"
It will be a great if it's possible, because you can check if your incoming data from a database in a specific user is corrupted, if X is malformed or null, etc...
Thanks all!
use Firebase Crashlyics instead. there you can report whenever you catch an Exception, instead of just logging to log-cat (currently only could find the Android documentation on fabric.io, which will soon be superseded by Firebase Crashlytics):
Crashlytics.log("Application Variables: userID="967234112", myJsonObject=null");
If you know you want to check something it is really easy. Instead of just relying on the code crashing, validate your input data to check if it is null. Then if it is you have a number of options:
use a service like Firebase Analytics to record the error
[not recommended] throw a more detailed exception with an error message
Crashes should only happen because of bugs in your code. You shouldn't be using them to record / trace input validation problems, as that really sucks for your users. Instead, write more robust code, and recover gracefully, while using a logging solution to find the bugs.
I am new to Android. Please help me to know about the best practice of using Android Logger. Do I need to keep a file somewhere in android and keep on writing logs into it, or writing of logs into file is not necessary. What could be the best practice.
My real intention is this.
Once we go live, if our customers come back and tell us that something crashed or does not work in their android , then how do we debug ?
In the web application, I would ask my server administrator to provide the log files. What do we do with the android application when there is no server error, but something failed in the phone. Is there a way to get logs from the phone.
Thanks
Ravi
Depends on what you need, you need logging for semi debugging your application than you can easily use the buildin Log functionality. Via Logcat you can easiliy see the logs.
http://www.vogella.com/tutorials/AndroidLogging/article.html
//Declare a tag
String TAG= "SomeActivity";
//Log
Log.d(TAG, "Hello World"); //debug
Log.e(TAG, "Hello World"); //error
If you want to have logging of multiple devices when you have released your app. Use a dedicated Log Framework (e.g. Log4J) and upload it to a server.
One tip (if you are using Eclipse, and not directly related to question) - Eclipse is very unreliable for viewing logs. For apparently no reason it completely stops displaying logs every now and then. A simple solution is to use command line tools for viewing logs. On Linux you can do :
$adb logcat MyTag:D *:S
If you want to capture logs to a file you can do:
$adb logcat -d > logcat.txt.
Hope this helps!
If you are planning to publish/distribute your application then storing logs in a file is possible but as per my opinion better not a better solution. You can configure online tools from your app.
Catch all sever exceptions and sending all the details regarding that exception. And configure any one logging tool into you application.
You can see log4j http://logging.apache.org/log4j/2.x/ or ACRA http://acra.ch/ or http://www.crittercism.com/
The Android logger's (android.util.Log) output goes to a console that you don't have to maintain. You don't actually have to manage files, just outputs.
You have 5 categories of log:
verbose: use Log.v(tag, message)
debug: use Log.d(tag, message)
info: use Log.i(tag, message)
warning: use Log.w(tag, message)
error: use Log.e(tag, message)
For example:
Log.e("MyActivity", "Oops... caught this exception: " + exception.getMessage());
The LogCat console (this is its name) allows you filtering by log level. This is a ceil filtering. For example, if you filter by 'warnings', you will see all warnings and errors, but not verbose, debug and info messages.
You'll find more details here in the official documentation.
My real intention is this.
Once we go live, if our customers come back and tell us that something crashed or does not work in their android , then how do we debug ?
In the web application, I would ask my server administrator to provide the log files. What do we do with the android application when there is no server error, but something failed in the phone. Is there a way to get logs from the phone.
If you use file for storage logs - it possible problem with performance if the file become big. So you need clean file in time.
As for me best solution use firebase or https://fabric.io/.
We use fabric.io.
Also you can use some wrapper for default Log class. This one https://github.com/JakeWharton/hugo for example
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
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.)
You will have to put a wrapper on top of Log where you can put functionality to control the log levels.
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.
I'm trying to play with debug in Android app and, when a breakpoint is encountered, Eclipse shows me a lot of windows, one of which is the "Interactive Console" with a prompt: I think to be able to enter statements and/or other stuff, but it seems to be disabled.
How can I work with it?
Window - Show View - Debug - Display
That will provide you with a window to enter statements and execute/inspect them.
This is a feature that's available in core eclipse platform. It works in most cases for Android based projects as well.
More info on the display view can be found here : http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/views/debug/ref-debug_view.htm
For a nice overview of the debugging features of Eclipse, check out this post : http://www.cavdar.net/2008/09/13/5-tips-for-debugging-java-code-in-eclipse/
The "Interactive Console" within the Debug View of Eclipse is used whenever the debugged program expects some input from the console.
It's possible you have other plugins installed that provide that view, and it's not meant to be used by Android Java code. See here (not accepted answer, but community-favored one).
You can use Logcat for and can see your check points using
android.util.Log.e("","CheckPoint");
You can toast your check points using Toast like:
Toast.makeText(this, "Write here what you want see",1 or 0).show();
1-> long time displaying and 0 for short time.
This toast display in your device screen when programe running.
You can use console screen for seeing output like print statements Ex---
java.lang.System.out.print("Checking");
use
try{
statements...;
}
catch(Exception e){
System.out.println("the error message "+e);
}
will show the error messages.
Is there anyone using Flurry to generate reports for uncaught exceptions that could post some sample code on how to do this?
I don't see any example via Flurry themselves, and though I've seen code samples of custom exception reporters, I haven't seen a simple example of how to implement the basic error reporting just using Flurry.
Thanks.
This is all good feedback. We're looking into adding full stack traces for error reporting which we'll hopefully see in our next major SDK release. We'll also look at filtering by device model.
In the meantime we've added a new REST API for exporting your error reports if you want to do your own analysis. If you need help using it you can just contact our support or message me.
Sean / CTO / Flurry, Inc.
Flurry does it automatically (if you have it running). However, the error reporting is lame. They only catch the message w/o giving you the stack trace, so you may end up seeing (for example) that people are getting lots of NullPointerExceptions, but you won't have any idea where, or how, they're happening. If you try to do it yourself with the FlurryAgent.onEvent() method you'll quickly discover that they limit you to 255 characters.
If you need detailed error reporting it really is better to roll your own right now.
I wasn't going to post this initially, but since it sounds like Flurry's error reporting sucks, you should check android-remote-stacktrace. It sends the stack trace to a url, which you can use to redirect it to an e-mail or just gather it on the server.
I'm not using it for uncaught exceptions , but you can catch it and then send it to flurry.
I am using bugsense for error reports. It catches full stack trace when an uncaught exception happens and also gives some useful information about the device - OS version, you app's version, is WiFi available on the device, etc. You can add custom messages and tags for specific events.
I've already fixed a couple crashes in my app thanks to it.
Since people are posting alternatives for getting stack traces, I'll recommend ACRA. ACRA can send the stack trace to a spreadsheet on google drive/docs. Or you can also have it send to your server if you wish too. By default it also includes phone model, android version, memory of device, and other data too.