Log Overhead in Published Apps

For published expo apps, do console.logs continue to consume device resources (i.e. space and cpu cycles), or are they somehow discarded (for example, does expo no-op the console.log() once it is published)?

The reason I ask is if they do utilize device resources, a developer may want to omit any logging probes from their published apps (depending on how many probes they have). This could be easily accomplished (at the app level) by “fronting” the console.log() with a layer that no-ops in production … however this would be pointless if it expo is already doing this.

The answer to this question is an important point that you may want to consider mentioning in your docs.

As a side topic (which is less important for me), are these logs available in some way in production … say a device-specific technique? I understand that expo does not have a logging strategy from this 3791 post.

Thanks for your help, and thanks for a great product!

2 Likes

Generally console related information can be found on the react native docs.
You are correct in your assumption, console.log can slow down a React Native project.

Some popular methods for silencing console logs are:

Babel plugin
yarn add babel-plugin-transform-remove-console


Brute Force

if (!__DEV__) {
  console.log = () => {};
}

I thought that production builds disabled console.* by default but I couldn’t find anything to verify that. :expressionless:

1 Like

Thanks for your reply @bacon.

Per your suggestion, I found this React Native Section that briefly mentions logging overhead and disabling.

1 Like

I know this is a dead thread, but FYI I was running into performance issues in my production Expo app (that I was struggling to repro in emulator) and the culprit turned out to be that I was console.log()ing some large objects.

So +1 for published apps stripping out console.log(), unless there’s some important reason not to.

maybe we could enable this by default when publishing… would need to be sure it’s obvious that this behavior exists though because there may be some cases where people depend on console.log in production. easiest way to remove logs: Customizing Metro - Expo Documentation

2 Likes