How to create txt file and also How to write all javascript exceptions to d same file

I want to log/write all javascript errors to one text file when ever an error happens in my JavaScript functions. using try catch block, i am catching exception. i need to log this exception to txt file. how can i achive this one sencha touch2

How can I do that. Please help me.

20 Jun 2012, 5:34 AM

mrsunshine

you can not write it to a FILE cause your browser has no access to the file system. you can only write it to the browsers console with console.log()

20 Jun 2012, 9:03 PM

Rameshlamani

Thanq for your reply.

21 Jun 2012, 2:16 AM

gubarez

You can also use localstorage... However, be aware, that if an iOS device has turned the private browsing on, you will be very likely to get lots of errors, and of course sencha to fail to load.

21 Jun 2012, 2:39 AM

Rameshlamani

Quote:

Originally Posted by gubarez

You can also use localstorage... However, be aware, that if an iOS device has turned the private browsing on, you will be very likely to get lots of errors, and of course sencha to fail to load.

so what is the best solution for this one. can i store all log errors(Exception) in local storage and how?

21 Jun 2012, 9:12 AM

rohdef

When you want to get exceptions I would say that local storage is a really bad way, since you woudn't be able to retrieve those, unless you have the device.

Much rather would I make some kind of remote service to which you can call and store your exceptions. If you are running the code on the same domain as the service you can use an ajax proxy for the purpose. If you have to run cross domain you'd have to do some tricks to make it work (probably making your own proxy).

But basically a remote service that stores them in an database and then combined with some kind of gui to view them would probably be the easiest way.

If you want to combine with the offline scenario you might be able to make a localstorage to cache it and then call the remote service when possible.