4

In Android, What is the difference between two namespaces,

  • android.util.Log
  • java.util.Logging

I am using android.util.Log. Now i am trying to save log to file, but file logging functions are not available in android.util.Log, how to do it ?

-- edit --

I already use Log.d(), Log.e() everywhere in my app, is there any way to redirect them to file, instead of changing code and adding another library ? In this answer microlog4android is recommended, but i'm not able to find any documentation or examples.

How CatLog is able to grab all logs and save it to a file? I want to do that in my application itself.

Community
  • 1
  • 1
Palani
  • 8,962
  • 11
  • 53
  • 62

2 Answers2

5

Similar questions have been asked here and here. They both suggest to have a look at microlog4android.

Community
  • 1
  • 1
kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
  • FYI: Microlog4Android is based on Microlog (for Java ME), which in turn is based on the original Log4j API. Thus it it not compatible with java.util.Logging. – Johan Karlsson Sep 19 '14 at 12:12
  • @kgiannakakis "Completely forget about java.util.Logging in Android." Why? – neteinstein Mar 24 '17 at 11:01
  • This is an old question and an old answer. At the time it was difficult to set up everything else than android.util.Log to log cat. Using java.util.Logging is fine. You can refer to http://stackoverflow.com/questions/4561345/how-to-configure-java-util-logging-on-android – kgiannakakis Mar 24 '17 at 11:15
1

Found similar question and answer

use logcat -f in order to dump it to a file in the filesystem.

Community
  • 1
  • 1
Palani
  • 8,962
  • 11
  • 53
  • 62
  • This is actually brilliant, if you can get away with requesting READ_LOGS permission. Then you have the whole log which might contain the reason you application blew up. – olafure Feb 21 '12 at 15:47