Why there is no official recommendation on how to retrieve records of Log class? I know that "Log" is:
` Log is a logging class that you can utilize in your code to print out messages to the LogCat.
Also:
` You can use LogCat from within DDMS or call it on an ADB shell.
But how can we save these records in a file?
I'm aware of a bunch of "unofficial" approaches to achieve that, but no where in android's documentation are they mentioned (hence the name "unofficial")
Why there is no official recommendation on how to retrieve records of Log class?
Because that is not supported. Quoting Dianne Hackborn:
Keep in mind that access to the logs has never been part of the SDK, and is still not part of the SDK
(from this android-developers thread discussing how you cannot hold the READ_LOGS
permission anymore)
But how can we save these records in a file?
Write them to a file yourself, at the point in time when you are doing the logging. For example, you could write your own wrapper that you use instead of Log.e()
and stuff directly, that writes to a file instead of, or in addition to, LogCat. IIRC, people have created LogCat support for various Java logging frameworks as well.