Hide strange unwanted Xcode logs
Solution 1
Try this:
1 - From Xcode menu open: Product
> Scheme
> Edit Scheme
2 - On your Environment Variables set OS_ACTIVITY_MODE
= disable
Solution 2
Building on the original tweet from @rustyshelf, and illustrated answer from iDevzilla, here's a solution that silences the noise from the simulator without disabling NSLog output from the device.
- Under Product > Scheme > Edit Scheme... > Run (Debug), set the OS_ACTIVITY_MODE environment variable to ${DEBUG_ACTIVITY_MODE} so it looks like this:
- Go to your project build settings, and click + to add a User-Defined Setting named DEBUG_ACTIVITY_MODE. Expand this setting and Click the + next to Debug to add a platform-specific value. Select the dropdown and change it to "Any iOS Simulator". Then set its value to "disable" so it looks like this:
Solution 3
OS_ACTIVITY_MODE didn't work for me (it may have been because I typo'd disable
as disabled
, but isn't that more natural?!?), or at least didn't prevent a great deal of messages. So here's the real deal with the environment variables.
https://llvm.org/svn/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb_private::Error
PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) {
// Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr
// if the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't
// require any specific value; rather, it just needs to exist).
// We will set it here as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag
// is not set. Xcode makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
// LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
// specifically want it unset.
const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
auto &env_vars = launch_info.GetEnvironmentEntries();
if (!env_vars.ContainsEnvironmentVariable(disable_env_var)) {
// We want to make sure that OS_ACTIVITY_DT_MODE is set so that
// we get os_log and NSLog messages mirrored to the target process
// stderr.
if (!env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE"))
env_vars.AppendArgument(llvm::StringRef("OS_ACTIVITY_DT_MODE=enable"));
}
// Let our parent class do the real launching.
return PlatformPOSIX::LaunchProcess(launch_info);
}
So setting OS_ACTIVITY_DT_MODE
to "NO" in the environment variables (GUI method explained in Schemes screenshot in main answer) makes it work for me.
As far as NSLog
being the dumping ground for system messages, errors, and your own debugging: a real logging approach is probably called for anyway, e.g. https://github.com/fpillet/NSLogger .
OR
Drink the new Kool-Aid: http://asciiwwdc.com/2016/sessions/721 https://developer.apple.com/videos/play/wwdc2016/721/ It's not surprising that there are some hitches after overhauling the entire logging API.
ADDENDUM
Anyway, NSLog
is just a shim:
https://developer.apple.com/library/content/releasenotes/Miscellaneous/RN-Foundation-OSX10.12/
NSLog / CFLog
NSLog is now just a shim to os_log in most circumstances.
Only makes sense now to quote the source for the other env variable. Quite a disparate place, this time from Apple internals. Not sure why they are overlapping. [Incorrect comment about NSLog
removed]
[Edited 22 Sep]: I wonder what "release" and "stream" do differently than "debug". Not enough source.
e = getenv("OS_ACTIVITY_MODE");
if (e) {
if (strcmp(e, "release") == 0) {
mode = voucher_activity_mode_release;
} else if (strcmp(e, "debug") == 0) {
mode = voucher_activity_mode_debug;
} else if (strcmp(e, "stream") == 0) {
mode = voucher_activity_mode_stream;
} else if (strcmp(e, "disable") == 0) {
mode = voucher_activity_mode_disable;
}
}
Solution 4
A tweet had the answer for me - https://twitter.com/rustyshelf/status/775505191160328194
To stop the Xcode 8 iOS Simulator from logging like crazy, set an environment variable OS_ACTIVITY_MODE = disable in your debug scheme.
It worked.
Solution 5
Please find the below steps.
- Select Product => Scheme => Edit Scheme or use shortcut :
CMD + <
- Select the
Run
option from left side. - On Environment Variables section, add the variable OS_ACTIVITY_MODE = disable
For more information please find the below GIF representation.
Hans Knöchel
Updated on July 14, 2022Comments
-
Hans Knöchel almost 2 years
When using the Xcode 8+ and creating a new blank project, the following logs appear when running the application:
2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, enable_level: 0, persist_level: 0, propagate_with_activity: 0 2016-06-13 16:33:34.406323 TestiOS10[8209:100607] Created DB, header sequence number = 248 2016-06-13 16:33:34.409564 TestiOS10[8209:100611] subsystem: com.apple.UIKit, category: HIDEvents, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0 2016-06-13 16:33:34.504117 TestiOS10[8209:100607] Created DB, header sequence number = 248 2016-06-13 16:33:34.548023 TestiOS10[8209:100607] subsystem: com.apple.BaseBoard, category: MachPort, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0 2016-06-13 16:33:34.568458 TestiOS10[8209:100608] subsystem: com.apple.FrontBoard, category: Common, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
Maybe someone already found a configuration for this to handle?
-
JAL almost 8 yearsSeems to just be debug logging information left over from development. Investigating...
-
Teja Nandamuri almost 8 yearsdid u turn off the dynamic linker api usage in xcode ?
-
Badal Shah over 7 yearsNot working for me in Xcode 8 seems like, this solution works for only Xcode 8 beta.
-
hwaxxer over 7 yearsI had this issue with Xcode 8.2.1 on El Capitan. Upgrading to macOS Sierra fixed the problem.
-
Paul Solt almost 6 yearsI'm still seeing the issue on Xcode 9.3, I've submitted Apple Bug #34767176 (Xcode 9 Displays System Framework Debug Print Statements), which is a duplicate of the open bug #32256894 Please submit a duplicate of the bug to Apple: bugreport.apple.com/web
-
Ishan Fernando about 5 yearsCheck this article mightytechno.com/x-code-disable-annoying-system-logs
-
Syclone0044 over 3 years@IshanFernando that link is 404 but here’s a copy of it: medium.com/@ishanfx/…
-
-
Hans Knöchel almost 8 yearsThought that as well, but I am neither using an watchOS application nor an watchOS simulator. But it still might happen to other Sims as well. Putting on hold for now and see if a certain Xcode 8 Beta will fix it over the next weeks / months.
-
JAL almost 8 years@HansKnoechel neither am I but I can confirm that this issue occurs with any application. No "official" word from Apple besides the release notes and some discussion at WWDC.
-
Hans Knöchel almost 8 yearsthanks, same here! We should talk about that tomorrow during WWDC, hehe :-)
-
SimplGy almost 8 yearsAlso happens for my iPhone 5s Simulator, probably all simulators.
-
SimplGy almost 8 yearsI couldn't get access to the link in this answer, despite being signed in, but this link works: adcdownload.apple.com/WWDC_2016/Xcode_8_beta/…
-
benrudhart almost 8 yearsI can confirm that this logging issue is still present in beta 2
-
Pez almost 8 yearsAdded a screenshot now I have enough privileges. I feel unlike the other answers, it is not necessary to have to launch the system wide logs when there is a work around directly within Xcode for those experiencing the same issue in Xcode console and just wanting to view what they are printing to the Xcode console.
-
SimplyLearning almost 8 yearsIs there a way to be notified when a new version of Xcode beta (ie. email subscription)? Was still running beta 0 and didn't notice there have been updates until saw this post @benrudhart
-
SimplyLearning almost 8 yearsIs there a way to be notified when a new version of Xcode beta (ie. email subscription)? Was still running beta 0 and didn't notice there have been updates until saw this post @mrahmiao
-
benrudhart almost 8 years@SimplyLearning you'll find this information all over twitter. But you might check out this official website from apple: developer.apple.com/news or their newsfeed to get updates when they publish them: developer.apple.com/news/rss/news.rss By the way: this still seems to be an issue in Xcode Beta 3.
-
mrahmiao almost 8 years@SimplyLearning New Xcode beta will be released with iOS beta
-
Rick over 7 yearsNot fixed in b6, either, for any kind of target.
-
AdamM over 7 yearsJust got Xcode 8 GM, and the issue still persists. Very annoying!!
-
Statik over 7 yearsJust downloaded Xcode Version 8.0 (8A218a) from App Store. The issue is still there.
-
nadein over 7 yearsIt also works on Xcode 8.0 release so I suggest it is the solution.
-
AdamM over 7 yearsThis is the best solution I have seen, I hope more people see this. This extra logging crap has been driving me crazy!! Cheers for solution!!
-
chrishale over 7 yearsFor anyone wondering how to get to that screen, you need to go to Product > Scheme > Edit Scheme or Cmd + <
-
Itai Spector over 7 years@iDevzilla, There's some issue with this solution, it removes some important stuff out of the log when using real device, like self logged data. Please overview it again, i'm not sure it's the most ideal solution.
-
iDevzilla over 7 years@ItaiSpector true, but you can create a different scheme to run on the device/simulator. So far this is the only solution I know that removes the useless log when running on the simulator.
-
Shai Mishali over 7 yearsJust ridiculous. Still there in Final MAS version.
-
Dmitry Isaev over 7 yearsUnfortunately, this option hides all
NSLog
s from a real device for me... -
dandan78 over 7 yearsI zipped, then deleted in case I need to restore.
-
jscs over 7 yearsAlways nice to see an answer that provides reasons and background rather than just the quick fix.
-
AirXygène over 7 yearsThis solution also hides some important logging in the simulator. For example, I missed the following warning "This app has crashed because it attempted to access privacy-sensitive data without a usage description." until I enabled again the OS_ACTIVITY_MODE
-
BaseZen over 7 years@AirXygène What about the values
release
orstream
instead? See my answer below. -
AirXygène over 7 years@BaseZen thanks for the suggestion, but I had no luck trying that.
-
BaseZen over 7 yearsI found this was unable to silence a lot of networking code, probably because it's lacking a subsystem name:
2016-09-23 15:09:21.354686 ProductName[8823:191206][] tcp_connection_start 3 starting
-
Sozin's Comet over 7 years@BaseZen Unfortunately, I only addressed OPs question which did not contain any tcp logging issues. You can create a new SO post if you need help addressing this issue.
-
dzensik over 7 yearsAs already said: The OS_ACTIVITY_MODE = disable deactivates all other logging with a NSLog.
-
Almas Adilbek over 7 yearsWorked this answer using OS_ACTIVITY_DT_MODE = NO
-
n8gray over 7 yearsDoes this produce different behavior than OS_ACTIVITY_MODE=disable? Is there some reason to prefer this solution?
-
Bocaxica over 7 yearsThe problem only resists in Simulator. Personally I don't believe it is a good idea to add the environment variable, because it also hides important logs like problems with Layout Constraints and among others the example @AirXygène gave. In simulator you can also hit "CMD + /" to open the console, it will give you the old-fashioned logs. Hopefully Apple will fix this issue in Xcode though, there is a lot of interest in this looking at the number of upvotes ;)
-
durazno over 7 yearsIt does not. It hides it all.
-
Prabu Arumugam over 7 yearsBut how to disable the same on a device? I mean the logs from a real iPhone or iPad shown in Window -> Devices menu? Very often, we need to see the logs of a distribution/production app installed on a device (non-debug mode).
-
Frizlab over 7 years“a real logging approach is probably called for anyway…” Seriously? os_log is THE logging solution dude… just because you don’t want to dive in does not mean it’s not great!
-
BaseZen over 7 years@Frizlab Yes I mention both in my post. See the "OR" ... I refer to
os_log
informally as the new Kool Aid. -
Jordan Smith over 7 yearsI'm still getting a lot of spurious logging in 8.1. Mostly weird socket and tcp connection stuff. Anyone else, or just me?
-
Abhishek Thapliyal over 7 yearsNo in 8.1 GM seed if we run on simulator then still logs system logs comes
-
iDevzilla over 7 yearsI've tested here (I'm using Version 8.1 (8B62) ) now, not GM, and the flag is no longer necessary.
-
Zhang over 7 yearsI've just downloaded Xcode 8.1 today (31/10/2016) and still seeing some debugging logging like this
[MC] Reading from private effective user settings.
from a blank new dummy project File > New > Project. -
Geoff Hackworth over 7 years@iDevzilla are you using macOS Sierra? I think the fix might require Xcode 8.1 and Sierra because I have removed the option and am still seeing the excessive logging when running Xcode 8.1. on El Capitan.
-
iDevzilla over 7 yearsYes. I'm using Sierra. Interesting that the OS changes this behavior.
-
NSNoob over 7 years
-
Rikco over 7 years@the comment above, please try again, I use Xcode 8.0 (8A218a) too and it does work fine.
-
cduhn over 7 years@NSNoob, Select your target and check its Build Settings to make sure you're not overriding the DEBUG_ACTIVITY_MODE variable at that level. Also make sure you edited the correct scheme for the target that you're running.
-
Lucas van Dongen over 7 yearsDoes it also hide the auto layout errors or this is some strange phenomena that only happens at my customer's computer? He has auto layout error and a screen full of these warnings
-
sbarow over 7 years@NSNoob make sure you don't have a space in the env variable.
-
Swany over 7 yearsToo bad this is not the accepted answer and too bad this answer is losing the up vote count. Much better answer IMHO since it only disabled OS_ACTIVITY_MODE for DEBUG builds on simulator.
-
Sentry.co about 7 yearsWait....On the second run it worked. Kudos for Gif Video. The best answers are always on the bottom!
-
GeneCode about 7 yearsThis workaround is nice. But do take note, recently NSLogs are truncated by XCode if it is too long.
-
RenniePet about 7 yearsThis didn't work for me, and neither did the top-voted answer. Using Xcode 8.2.1 on OS X 10.11.6 El Capitan. But what did work was a combination of this answer and the one by BaseZen, using OS_ACTIVITY_DT_MODE instead of OS_ACTIVITY_MODE. (And unexpectedly for me at least both "NO" and "disable" turned off the rampant logging.)
-
RenniePet about 7 yearsMy testing seems to indicate that when using OS_ACTIVITY_DT_MODE that both "NO" and "disable" turn off the rampant logging.
-
Marco Pappalardo about 7 yearsIn Sierra and Xcode 8.1 the logs have been removed. So it is better to remove this flags as it could interfear with thrown exceptions by the system while debugging
-
Misha almost 7 years@RenniePet, that's exactly what did it for me. Thanks!
-
keronsen over 6 yearsI also had to use OS_ACTIVITY_DT_MODE instead of OS_ACTIVITY_MODE for it to work. Using XCode 8.3.3 on OSX Sierra 10.12.6
-
Cœur over 6 years"release", "info", "default" will show NSLog on Xcode 9. "debug", "stream", "disable" will hide NSLog on Xcode 9.
-
Cœur over 6 yearsThis solution will hide all NSLog starting with Xcode 9. To keep NSLog, replace
disable
withdefault
. -
Cœur over 6 yearsThis solution will hide all NSLog starting with Xcode 9. To keep NSLog, replace
disable
withdefault
. -
Cœur over 6 yearsThis solution will hide all NSLog starting with Xcode 9. To keep NSLog, replace
disable
withdefault
. -
Cœur over 6 yearsThis solution will hide all NSLog starting with Xcode 9. To keep NSLog, replace
disable
withdefault
. -
LinusGeffarth over 6 yearsOMG who does not type "disabled"?? Thanks for pointing this out!
-
GeoffCoope over 6 yearsI was getting all sorts of logs that I did not want, tried this method which stops NSLog from working. Deleted the var and now NSLog is back and the extra logs that I didn't want have stopped too. Must have cleared something hanging around in xCode 9. Anyway, cheers :)
-
roocell over 6 yearsOS_ACTIVITY_MODE=disable caused problems with my packager when trying to run on device. but not at first. only after developing my app for another several hours. At that point I was getting a jsbundle error (essentially device wasn't talking to the packager). The fact that this turned up only later made it VERY difficult to realize this env variable was the issue.
-
Paul Solt almost 6 yearsI'm still seeing the issue on Xcode 9.3, I've submitted Apple Bug #34767176 (Xcode 9 Displays System Framework Debug Print Statements), which is a duplicate of the open bug #32256894 Please submit a duplicate of the bug to Apple: bugreport.apple.com/web
-
Alyoshak over 5 yearsHow to filter the noise now that I've had to go back and replace disable with default? I can see my NSLog statements in the console, but am getting all the noise again.
-
szx over 5 yearsFor me this does disable NSLog output on the iOS simulator, I don't see this is different from simply using
disable
as the value.default
also disables NSLog logs... -
Tuan Anh Vu over 5 yearsThis worked after I tried it for the second time, like another user pointed out in a comment from another answer. Weird.
-
bauerMusic over 5 yearsWe use a tag-prefix for filtering. Some issues are: Multiple lines will only show the first one. When using lldb for debugging, you need to toggle the filtering. Really really sad that as of today, the console is extremely limited. We have an App for decent filtering, but we need to copy/paste from the console. How sad.
-
Abhishek Maurya almost 4 years@Cœur you are a saviour, Everyone was saying it to disable, but you gave me the best answers, Thanks a lot man.
-
Tim over 3 yearsNote, that this breaks signposts on real devices: stackoverflow.com/a/57187309/2982854
-
Abhishek Maurya over 3 yearsit's better to set it 'default' instead of 'disable', setting 'enable' will show each and every log, but disable will also disable every log (even useful logs from pods), so better use 'default' as it will only hide useless logs
-
ScottyBlades over 2 yearsI'm getting this in 2021
-
Vincent about 2 yearsI do not think that this a good answers. What is does is just hiding messages. The messages still remain but are not shown. Also constraints warning are hidden which may cause unpredictable / unwanted actions from the app.| IMHO a bad answer