The joy of programming

Log all the things with Log Aspects

March 10, 2019

For when you really need to log all the things

xcodebuild

xcodebuild -DVTDefaultLogLevel=3

This will set most logging to maximum level. A sample app will result in about 50 lines of logs at DVTDefaultLogLevel=1 and about 20000 lines at DVTDefaultLogLevel=3.

Xcode

/Applications/Xcode.app/Contents/MacOS/Xcode -DVTDefaultLogLevel 3

This can crash Xcode due to bugs in logging. Enabling individual log aspects should work though.

Log Aspects

Logging can be controlled on a more fine grained level.

Available aspects when running xcodebuild:

AuxiliaryFilesWriting
BlockQueue
Build
BuildConfigurations
BuildContext
BuildInfo
Building
BuildMessages
BuildPlanCreation
BuildRuleLoading
BuildSettingExpansion
BuildSettings
BuildTaskCreation
Cache
CachePruning
Caching
Capabilities
CodeSign
CodeSignUI
CommandInvocation
CommandLineBuildTiming
ConfigInspectionContext
Container
DepCommandTraversal
Dependencies
DependencyAnalysis
DependencyGraph
DependencyGraphCreation
DependencyGraphCreationMetric
DependencyGraphLock
DependencyIssue
DepNodeTraversal
DerivedInfo
DerivedTargetAttributes
DocumentFileTypes
DTDeviceKit
DVTArchitecture
DVTAssertionEnvironment
DVTCodesigningAllTheThings
DVTCollectionChecking
DVTCommandLineTool
DVTDevice
DVTDeviceSearch
DVTDeviceType
DVTDirectoryBasedCustomDataStore
DVTFilePath
DVTFilePathFSEvents
DVTFilePathICloud
DVTFilePathLogMetrics
DVTFileType
DVTInvalidExtension
DVTMacroExpansionParsing
DVTMacroNamepsace
DVTMixIn
DVTNDM
DVTPlatform
DVTPlugInExtensionFaulting
DVTPlugInLoading
DVTPlugInLocator
DVTPlugInManager
DVTPlugInQuery
DVTProvisioningProfileManager
DVTProvisioningProfileSourceLoadingTime
DVTRegularExpression
DVTSDK
DVTSigningCertificate
DVTSigningCertificateManager
DVTSigningCertificateSource
DVTSourceScanner
DVTSourceSpecificationLoading
DVTToolchain
Executable
FileInfoCaching
FileRefCaching
FileSuffixMapping
FileTypeDetection
FSWatcher
GenericOutputParsing
GroupEnumerator
HdrScanning
Headermap
HeadermapCreation
Headermaps
HeaderScanning
IBMessageChannel
IDEActivityLogSection
IDEBuildDebugMetric
IDEBuilderDebug
IDEBuildOnlyMetric
IDEBuildOperationDebug
IDEBuildOperationDependencies
IDEBuildOperationMemorySnapshot
IDEBuildOperationQueueSetResourceManagement
IDEBuildOperationTiming
IDECommandLineBuildLogDebug
IDEContainerDebug
IDEContainerFSEventsDebug
IDEContainerItemSCMDebug
IDEContainerQueryDebug
IDEEntitlementsFile
IDEExecutionEnvironmentExecuteOperation
IDEFileReferenceDebug
IDEImplicitDependenciesDebug
IDEInitialization
IDEKVO
IDELogStore
IDENotifications
IDEProvisioningManager
IDEProvisioningManagerPerformance
IDERunContextManager
IDERunContextManagerPerformance
IDERunDestination
IDESourceControl
IDETestableDataSource
IDEWorkspaceLoading
IDEXCBuildPlanOnlyMetric
IndexingInfo
IntegrityChecking
iOSSimulator
MacroExpansionScope
MessageQueues
Modules
NativeBuilding
Operations
OperationStatus
OptionCategories
PersistedBuildResults
PlatformLoading
PlugInCompilers
PluginLoading
PlugInTools
PrecompiledHeader
PrepareForBuilding
ProjectLoading
ProjectLocalization
ProjectReference
ProjectSaving
ProjectTiming
PropertyValue
RecursiveSearchPaths
RelevantToolSpecs
SDKLoading
SimplePreprocessor
SourceFileFiltering
SpecificationLoading
SpecificationLoadingTiming
SpecificationsDebug
SupportedBuildTools
Target
TargetCache
TargetCaches
ThreadedOperations
Unarchiving
WorkQueueProcessing
XBS
xcodebuildDebug
XCPropertyValue

To enable individual log level, add it to the commandline with LogLevel postfix:

xcodebuild -xcodebuildDebugLogLevel=3

Romans-MBP:GitHubActionsXCSApp rd$ xcodebuild -xcodebuildDebugLogLevel=3 build
2019-03-10 23:39:38.282 xcodebuild[52992:4673197] [MT] xcodebuildDebug: Working directory is '/Users/rd/_sample/GitHubActionsXCSApp'
User defaults from command line:
xcodebuildDebugLogLevel = 3
2019-03-10 23:39:38.294 xcodebuild[52992:4673197] [MT] xcodebuildDebug: Scanning for project files (xcodeproj, xcode, pbproj, pbxproj) in /Users/rd/_sample/GitHubActionsXCSApp
2019-03-10 23:39:38.294 xcodebuild[52992:4673197] [MT] xcodebuildDebug: Looking for files with extensions (xcodeproj, xcode, pbproj, pbxproj) in directory /Users/rd/_sample/GitHubActionsXCSApp {
2019-03-10 23:39:38.294 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename GitHubActionsXCSAppTests
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename GitHubActionsXCSApp.xcodeproj
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | --> accepted
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename GitHubActionsXCSApp
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename level3.log
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename GitHubActionsXCSAppUITests
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename build
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename level2.log
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename level0.log
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename .git
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename level1.log
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: | filename level5.log
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: } found 1 file
2019-03-10 23:39:38.295 xcodebuild[52992:4673197] [MT] xcodebuildDebug: Found projects: GitHubActionsXCSApp.xcodeproj
note: Using new build system
note: Planning build
note: Constructing build description
** BUILD SUCCEEDED **

More aspects could be available in Xcode and at runtime if a framework is loaded dynamically.


Roman Dzieciol

Written by Roman Dzieciol