简体   繁体   中英

Is there a way to trace log of android app that is published

I've a complete admin app which I've published just a few days back. Sometimes end users report issues with the published application while it's not reproducible at my end.

Is there a tool available for tracing my log generated by any device which is using my application?

Use one of these services (of course you could find other, but these are the most popular):

I personally use crashlytics, because they show the exceptions thrown very good.

-- EDIT -- from you latest comment, there is no way (I now) to obtain logcat output without root programatically

Crashlytics (by Fabric) offers Custom Logging and Custom Keys which provide a way of logging remotely to their servers.

I have used this with great success in the past for exactly this reason - it gives you insight to the app flow without having to get physical access to the device.


The default call for logging a message is:

  • Crashlytics.getInstance().core.log(int priority, String tag, String msg);

This will write to LogCat as well as to Crashlytics.

Alternatively, just provide a message to skip logging to LogCat. As per example on website:

  • Crashlytics.getInstance().core.log("Higgs-Boson detected! Bailing out...");

You can use Google Analytics API part for handling exceptions . It also provides facilities for collecting stack traces. (this is an exmaple from the API pages)

// Using StandardExceptionParser to get an Exception description.
try {

  // Request some scores from the network.
  ArrayList<Integer> highScores = getHighScoresFromCloud();

} catch (IOException e) {
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
    TrackerName.APP_TRACKER);

  t.send(new HitBuilders.ExceptionBuilder()
      .setDescription(
          new StandardExceptionParser(this, null)
              .getDescription(Thread.currentThread().getName(), e))
      .setFatal(false)
      .build()
  );

  ... // Display alert to user that high scores are currently unavailable.
}

Afterwards all tracked stracktraces will be display in the Google Developer Console in the tap of you app.

Google开发者控制台中的“崩溃和ANR”(图片来自网络)

You can also add an Listener for catching unhandled exceptions. So whenever an exceptions occours which you did not expect whis handler will be invoked.

Thread.setDefaultUncaughtExceptionHandler(new MyReportHelper());

Of course you should always try to catch and handle all exceptions which you know of, this handler is only for emergencies. For more details how an handler could look like see here .

We may find a lot of tools if googled but I think it will be good to use our own solution for this as the app might log sensitive info.

If your app is communicating with your own backend server then you can write an additional webservice which can save (in db) whatever exceptions occurring in the app. You have to send the app log details to the server to save it in the db. If there is an administrative web account for this app you can add an option to list these logs from the db. This will be secure as you are not sending app log to a third party tool to log.

Another secure solution is hosting any tool like this (which can show realtime log from your device) in your own server.

The previous answeres were mainly talking about crash reporting. But there is much more to logs than crash reporting.

Exactly for this, we created Shipbook.

Shipbook gives you the power to remotely gather, search and analyze your user mobile app logs and exceptions in the cloud, on a per-user & session basis.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM