On Apr 22, 5:41 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> > Iam Writing an Application in which i need to put all the system.out or
> > log.e logs into a file which will be generated in the phone system.

> The following snippet was recently added to AndroidSnippets.org:
>
> http://www.androidsnippets.org/snippets/35/
>
> I have not tried the technique demonstrated there, and it scares me
> slightly, but it is probably worth trying.

You can also just pop open the /dev/log entry (assuming appropriate
permissions) and read it directly.  The format is laid out in core/
include/cutils/logger.h:

struct logger_entry {
    uint16_t    len;    /* length of the payload */
    uint16_t    __pad;  /* no matter what, we get 2 bytes of padding
*/
    int32_t     pid;    /* generating process's pid */
    int32_t     tid;    /* generating process's tid */
    int32_t     sec;    /* seconds since Epoch */
    int32_t     nsec;   /* nanoseconds */
    char        msg[0]; /* the entry's payload */
};

The "msg" field has a one-byte priority, followed by the null-
terminated tag, followed by the message (which I don't think is null
terminated -- "len - taglen - 1" is the message body length).

This sort of manipulation is pretty awkward in Java, and you still
have to format it "nicely".  But once you've got that written you can
apply whatever layout / filter rules you want.

If you only need System.out and System.err for *your* process, it's
easy enough to redirect them (and in fact this is what the Android
framework does to put them in the log file instead of stdout/stderr).

All three logs (/dev/log/{main,radio,events}) use the layout shown
above, but the contents of "msg" may vary ("events" is completely
different).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to