Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS logging doesn't work #9441

Closed
jchoi18 opened this issue Aug 17, 2016 · 46 comments
Closed

iOS logging doesn't work #9441

jchoi18 opened this issue Aug 17, 2016 · 46 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@jchoi18
Copy link

jchoi18 commented Aug 17, 2016

Hello, currently using React-Native .31 on Mac. Everything was working fine yesterday but all of a sudden my logging isn't working... There's no error messages just react-native log-ios doesn't output any logs. I've tried rebuilding the project / restarting simulator (iPhone 6 / iOS 9.3), but nothing. Any suggestions to debug what's wrong?

@jchoi18
Copy link
Author

jchoi18 commented Aug 17, 2016

Logs seem to be working fine when I build the app through Xcode. Seems like a bug still so I'll leave this issue open.

@npomfret
Copy link
Contributor

Are you talking about a dev or production release? I can't get logs to appear in a production app.

@charpeni
Copy link
Contributor

@facebook-github-bot label Icebox

@charpeni
Copy link
Contributor

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/ios-logging-doesnt-work

ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

@charpeni
Copy link
Contributor

@facebook-github-bot close

@facebook-github-bot
Copy link
Contributor

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

@facebook-github-bot facebook-github-bot added Ran Commands One of our bots successfully processed a command. Icebox labels Nov 14, 2016
@rgstephens
Copy link

rgstephens commented Nov 28, 2016

I just ran into this problem. Logging has been working fine in Dev mode and all of a sudden, no console.log output to stdout in the console window of the react-native log-ios. However, I can see the messages in the IOS simulator under the Debug > Open System Log.

@tomazahlin
Copy link

Same problem happened for me yesterday. Any solutions?

@raould
Copy link

raould commented May 16, 2017

Similar-but-different issue (Mac OS X, iOS Simulator, Nuclide) I am hitting at the moment: My console.log()s all were appearing successfully in my Terminal output from "react-native log ios", but now they are not. I do see other log messages, just not mine.

I just tried doing Cmd-D and saw "Stop Remote JS Debugging" so clicked that and... my console messages are now appearing in the logs again, hooray.

In case that helps anybody else...

@ademcan
Copy link

ademcan commented Sep 18, 2017

I am having similar issues recently. I can see all the console.log() outputs if I run my app from Xcode (within Xcode Debug area), but I don't see the correct log if I run via the command line (which I was used to do). I start my app with react-native run-ios; react-native log-ios which says BUILD SUCCEDED but then does not show any proper message that I indicated in console.log().
This basically happened after uprading to Xcode 9... Does anyone have an idea about what could cause this weird behaviour?
Thanks.

@matthewlarge
Copy link

@ademcan I'm experiencing the same thing as you. Started once I updated to Xcode 9.

@jesusgp22
Copy link

same issue here, as stated by @matthewlarge and @ademcan

@ivzeus
Copy link

ivzeus commented Sep 28, 2017

after upgrading to XCode 9 I can't get simulator log anymore (using react-native log-ios). However, I was able to get the log using Console.app

@ademcan
Copy link

ademcan commented Sep 28, 2017

I gave up and am running my RN app from Xcode only (to be able to see the logs)...

@chiragpurohit71085
Copy link

chiragpurohit71085 commented Sep 29, 2017

Facing the same issue as @ademcan (After upgrading to xcode 9, I am no longer able to view my logs)

@prjmax
Copy link

prjmax commented Oct 2, 2017

Same issue here.... any update?

@campoblanco
Copy link

Same

@ivzeus
Copy link

ivzeus commented Oct 3, 2017

guys, for now you can use the Console.app of MacOS to get logs from the simulator

@wellyshen
Copy link

I can't see console.log of xCode9 iOS simulator too....

@jslok
Copy link

jslok commented Oct 13, 2017

I can't see logs using react-native log-ios or in xcode with xcode 9.

@ivzeus, how do I see all my console.log in Console.app? When I look in Devices > iPhone 7 (simulator) there are none of my console.log.

@guperrot
Copy link

This issue is still current and should be reopened.
The console location changed with XCode 9 and thus react-native look at the wrong logs.

@edisonthk
Copy link

I can't see any console.log message by react-native log-ios also.

@ivzeus
Copy link

ivzeus commented Oct 15, 2017

@jslok that's strange, I just open Console app and all my logs are there
screenshot at oct 15 15-23-15

@ajkhatibi
Copy link

ajkhatibi commented Oct 17, 2017

@ivzeus how do you stop the live feed and just display logs?

@guperrot
Copy link

@ivzeus yes this is the right place using the UI, but react-native log-ios command line picks the wrong logs if XCode 9 is installed.

@ivzeus
Copy link

ivzeus commented Oct 18, 2017

@ajkhatibi: I add some prefix in my console.log and filter them out
@guperrot: yeah so now I just wait for new update

@wootwoot1234
Copy link

Any updates on this?

@jonathan-stone
Copy link

@ivzeus My console app (spotlight search -> "console" -> console app) doesn't look like that. What steps did you take to get there?

@ajkhatibi
Copy link

It actually started working for me now. I stoped using expo and just regular react native init and when I load the app I just use the remote debugger and it works fine. Not sure sure way it might be because of expo

@HadrienPierart
Copy link

If you were unlucky like me to have your app default setup running as "Release", you will not see the logs in xcode or the Console App.
Change this setting in xcode (in Edit Scheme of your phone config), rebuild the app and you should start seeing your logs !
Indeed, prefixing the logs does help filtering after that.

@cvoisey
Copy link

cvoisey commented Jan 4, 2018

I'm experiencing the same. Any resolutions?

@cbartondock
Copy link

Can confirm that this is an issue. I see the following "note" upon running react-native log-ios:

"Most system logs have moved to a new logging system. See log(1) for more information."

@ethanyuwang
Copy link

@HadrienPierart Where exactly is Edit Scheme?

@sinewave440hz
Copy link

As @cbartondock commented, the text: "NOTE: Most system logs have moved to a new logging system. See log(1) for more information." is visible in the log and console.logged text does not show up in this log - and this applies to both the log visible using react-native log-ios and the log available in the Simulator at Debug->Open System Log... A workaround is to use the Console app in OS X- selecting the simulator in question there shows a similar log but includes console.logged text as well! In my case, this occurred on rn 0.54.2 with a fresh install using react-native init.

@tafelito
Copy link

running the app from xcode does show console logs but running react-native log-ios does not. Logs are also shown in chrome devtools console when remote debugging. System logs as @sinewave440hz pointed it out shows the same as running react-native log-ios

Running xcode 9.3 and react-native 0.54.4

@scottmas
Copy link

This should be re-opened. Not working in RN 55

@ghost
Copy link

ghost commented Apr 22, 2018

If you want to watch your IOS simulator JS console.log lines from the terminal you can use:

log stream --predicate '(processImagePath contains "yourAppName") and senderImageUUID == processImageUUID'

@npomfret
Copy link
Contributor

@enzomd thanks, that looks incredibly useful. Where did you discover this?

@ghost
Copy link

ghost commented Apr 23, 2018

@npomfret Reading the man log page, trial and error. If you add --style json it will reveal the keys you can use in the --predicate.

@koloff
Copy link

koloff commented Apr 25, 2018

Thank you @enzomd, do you know how to remove the metadata from the logs?

@ghost
Copy link

ghost commented Apr 25, 2018

@koloff Save this to watch-ios-logs.js, then chmod +x watch-ios-logs.js, run in a shell with ./watch-ios-logs.js.

Shell pipes do not work with the output from /usr/bin/log, I am not sure why.

Also note that some log sources (other than the iOS simulator) /usr/bin/log outputs invalid JSON, I think this is a bug.

#!/usr/bin/env node
'use strict';
const moment = require("moment");
const {spawn} = require('child_process');

const args = [
    'stream',
    '--predicate', `(processImagePath contains "yourAppName") and senderImageUUID == processImageUUID`,
    '--style', 'json'
];

const lg = spawn('log', args);

lg.stdout.on('data', data => {
    const str = data.toString();

    // Assumption: { is always at the end of a line, } at the start of line.
    const m = str.match(/\{$[\s\S]+?^\}/mg);
    if (m === null) {
        return;
    }

    const all = m.map(str => JSON.parse(str));

    all.forEach(({timestamp, eventMessage}) => {
        const time = moment(timestamp).format("H:mm:ss");

        console.log([time, eventMessage].join(", "));
        console.log("\n");
    });

});

lg.stderr.on('data', data => {
    console.log(`stderr: ${data}`);
});

lg.on('close', code => {
    console.log(`child process exited with code ${code}`);
});

@tafelito
Copy link

thanks @enzomd that did work!
I noticed it that there is a note when running react-native log-ios that says 'Most system logs have moved to a new logging system. See log(1) for more information.' Maybe something on the script is outdated after 11.3

@koloff
Copy link

koloff commented Apr 29, 2018

Thank you @enzomd!

@ybaidiuk
Copy link

ybaidiuk commented May 8, 2018

on real device if i runnung "react-native log-ios" i get No active iOS device found. how it possible to get the logs

@NerdcoreSteve
Copy link

All I ever see when I run react-native log-ios is a ton of messages that say
com.apple.CoreSimulator.SimDevice.7115B868-137E-4459-8493-7D9B3B5050A7[1051] (com.apple.videosubscriptionsd) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests