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

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.