Write / read log data to file in android

how to read / write log data to a text file in android, the file should be a res folder.

+4
source share
5 answers

You can take a look at microlog4android. They have a solution ready to register to a file.

http://code.google.com/p/microlog4android/

+5
source

I donโ€™t know what exactly you need to do, but there are two excellent applications that allow you to remotely receive device logs.

The first is โ€œLog Collectorโ€: http://code.google.com/p/android-log-collector/
"Log Collector" has the ability to send a log to the device by mail, sms, tweet or whatever you want.

The second one I know is "DroidDrop": ( http://github.com/CarmenD/DroidDrop--Remote-Logging )
With DroidDrop, you can do remote logs inside your applications.

Perhaps one of these applications does what you wanted, but if it is not, maybe you are still lucky because both of them are Open Source, so you can check the code to see how they get the log (I I think part of the actual writing of the journal in the file is easy for you).

I specifically recommend that you take a look at the CollectLogTask class in the SendLogActivity.java file from "Log Collector".

PS: More sample logging apps can be found here: code.google.com/p/android-random/downloads/list

Good luck

+2
source

When you work with android ... at runtime you will not find much help for the log.

The best way to get your data is to send the necessary data to some external server.

I run my web application on the server ... to get log information, I run another tomcat server and got log information there.

use dojo.xhrPOSt method ...

try{ var xhrArgs = { url: "/mum/proxy/http/9.182.241.35:8080/com.error.android.mashup/xmlContentReader", postData: ans, handleAs: "text", load: function(data) { // alert("data:"+data); }, error: function(error) { //We'll 404 in the demo, but that okay. We don't have a 'postIt' service on the //docs server. alert("error:>"+error); } }; var ret = dojo.xhrPost(xhrArgs); } catch(ex){alert(":::"+ex);}` 

here / mum / proxy was used bcz my application was running on a different server and I am collecting the result on another server ... hope this helps ....

0
source

It is not easy to get journal entries in Android. One way to do this is to write your own wrapper around / replace for android.util.Log and write to a text file somewhere in addition to calling Log. Then you can copy this text file to an SD card or upload it to your server or do whatever you need with it.

0
source

Mark my post here about HockeyApp and ACRA However .. Try to use as many Google services already provided for Android through third-party libraries ..

Hope this helps you.

0
source

Source: https://habr.com/ru/post/1304007/


All Articles