如何无需设置OS_ACTIVITY_MODE=disable停止控制台持续显示[MC] Invalidating cache
Hey there! I’ve fought this annoying [MC] cache invalidation spam more times than I can count, so I totally get why you want a better solution than nuking all OS activity logs with OS_ACTIVITY_MODE=disable. Here are targeted ways to silence just those messages while keeping useful logs intact:
Filter logs directly in Xcode
This is the quickest fix. Head to the Xcode console’s search bar at the bottom, and enter either:NOT [MC]to filter out any log line containing the[MC]tag- Or the more precise
NOT subsystem:com.apple.metadata(since all those [MC] messages come from Apple’s Metadata subsystem)
You can even save this filter by clicking the "Save" icon next to the search bar, so you don’t have to retype it every time.
Tweak log levels via environment variables
Instead of disabling all activity logs, adjust the default log stream level to ignore low-priority debug messages:- Open your app’s Scheme editor (Product > Scheme > Edit Scheme)
- Go to the Run tab > Arguments > Environment Variables
- Add a new variable:
OS_LOG_DEFAULT_STREAM_LEVELand set its value toinfoorwarning
This will suppress debug-level logs (which those [MC] messages fall under) while keeping info, warning, and error logs visible.
Check for problematic dependencies or system updates
Sometimes these spammy logs are triggered by third-party libraries (especially those handling network requests, caching, or file system operations) that repeatedly interact with Apple’s Metadata framework. Try updating your dependencies to their latest versions—many maintainers fix issues that cause excessive system log calls. You can also try updating to the latest iOS/Xcode version, as Apple occasionally patches overly verbose logging in system frameworks.Programmatically filter logs (advanced)
If you need even more control, you can use Apple’sOSLogAPI in your code to configure log filtering. For example, you can explicitly set the log level for thecom.apple.metadatasubsystem to be ignored, though this requires a bit more setup in your app’s logging configuration.
These approaches let you keep an eye on important system and app logs while getting rid of that endless stream of [MC] invalidation messages—way better than the brute-force OS_ACTIVITY_MODE disable!
内容的提问来源于stack exchange,提问作者kiran

