React-native: iOS logging doesn't work

Created on 17 Aug 2016  路  46Comments  路  Source: facebook/react-native

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?

Ran Commands Locked

Most helpful comment

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.

All 46 comments

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.

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

@facebook-github-bot label Icebox

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.

@facebook-github-bot close

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

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.

Same problem happened for me yesterday. Any solutions?

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...

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.

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

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

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

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

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

Same issue here.... any update?

Same

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

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

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.

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.

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

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

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

@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.

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

Any updates on this?

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

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

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.

I'm experiencing the same. Any resolutions?

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."

@HadrienPierart Where exactly is Edit Scheme?

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.

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

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

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'

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

@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.

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

@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}`);
});

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

Thank you @enzomd!

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

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.

Was this page helpful?
0 / 5 - 0 ratings