Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I log my output to .txt file instead of the terminal in Expo?

I am using Expo for my React Native Application. console.log(responseJson) writes the App.js output to the my zsh terminal however my Json gets truncated with the following message.

...(truncated to the first 10000 characters)

I want to be able to view the entire Json by logging the output to a .txt file on my app directory.

Is there a solution or workaround without having to eject my Expo app to ExpoKit?

like image 677
Kewal Shah Avatar asked Dec 11 '25 02:12

Kewal Shah


1 Answers

Alternative solution:

install json-server

npm install -g json-server

create a new file for logs:

echo '{"logs": []}'> logs.json

start json-server:

json-server logs.json

now in your code you can store:

let veryLargeTextWorks = "1234567890";
    for (let i = 0; i < 11; i++) {
      veryLargeTextWorks += veryLargeTextWorks;
    }
// veryLargeTextWorks.length == 20480
axios.post("http://localhost:3000/logs", {
      date: new Date(),
      msg: veryLargeTextWorks
    });
like image 106
Tiago Cunha Fernandes Avatar answered Dec 13 '25 20:12

Tiago Cunha Fernandes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!