When you set OS_ACTIVITY_MODE to disable
, you disable all log outputs for processes that have access to this environment variable, for example the simulators.
When you set the value to either info
or debug
it enables the corresponding logging mode unless it is disabled in the logging preferences for certain log categories.
So in order to enable only a certain log category, you have to enable OS_ACTIVITY_MODE, that is, set it either to info
or debug
or leave it at the default, and then disable logging for all other categories.
For more information how to do this see the man page for log, type man log
in the console.
Get the current log preferences for simulators:
In the console type:
xcrun simctl spawn booted log config --status
That basically means: apply log config -status
to all booted simulators.
This may print the following to your console:
System mode = INFO STREAM_LIVE PRIVATE_DATA
Get the status for a certain category and subsystem
xcrun simctl spawn booted log config --status --subsystem com.mycompany.myapp --category network
This may print the below to the console:
Mode for 'com.mycompany.myapp(network)' INFO PERSIST_DEFAULT
Get Help
For help, the tools xcrun simctl
and log
have nifty man pages and help pages.
For example:
type log config --help
into the console, it prints:
usage: log config [options] --mode <modes>
or: log config [options] --status
or: log config [options] --reset
description:
Read or configure settings for the logging system. Configuration
can act system-wide; or on a subsystem, category, or process level.
options:
--category <name> Get/set settings for a given category
--mode <modes> Enable given modes
--process <pid> | <name> Get/set settings for a given process
--reset Reset settings to defaults
--status Show current settings
--subsystem <name> Get/set settings for a given subsystem
modes:
Modes can be specified as a comma-separated list of key:value pairs.
Valid keys and their values are:
level off | default | info | debug
persist off | default | info | debug
stream live | default
Set the log level for a specific subsystem and category
xcrun simctl spawn booted log config --mode "level:debug" --subsystem com.mycompany.myapp --category network
Get the status again for this sybsystem and category will print:
Mode for 'com.mycompany.myapp(network)' DEBUG PERSIST_DEFAULT