tags:

views:

490

answers:

5

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

Thanks in advance

Aswan

A: 

you can't write to res folder - it's for importing data to application

fazo
thankq but i need log file data into a text file please help me. i need to send that file to remote server
Aswan
+1  A: 

I don't know what exactly you have to do but there are two great applications that allow you to get the logs of the device "remotely".

The first one is "Log Collector": http://code.google.com/p/android-log-collector/
"Log Collector" has the ability to send the log on the device via 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 from inside your applications.

Maybe one of this apps do already what you wanted but if that is not the case, maybe you are still lucky because both of them are Open Source, so you can check the code to see how they obtain the log (I guess the part of actually writing the log in a file is easy for you).

I specially recommend you to take a look at the class CollectLogTask in the SendLogActivity.java file, from "Log Collector".

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

Good luck!

Edu Zamora
A: 

When you are working with android... at runtime you don't find much help for log.

better way to get your data is to send required data to some external server.

i'm running my web-app on was server.... to get log info i run another server tomcat and got the 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's 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 app was running on another server and i'm collecting result on another server ... hope this will help....

R_Dhorawat
A: 

It's not easy to get log statements in Android. One way to do it is to write your own wrapper around / replacement for the android.util.Log and write to a text file somewhere in addition to calling Log. Then you can copy this text file to the sdcard, or upload it to your server, or do whatever you need to do with it.

Mike Kale
+3  A: 

You could take a look at microlog4android. They have a solution ready to log to a file.

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

darius
The microlog4android project has just released version 1.0. Try it out!
Jarle Hansen