Skip to content

Failed to initialize logging system in Xcode

Problem

When building and running Swift applications in Xcode, developers may encounter the following error:

Logging Error: Failed to initialize logging system. Log messages may be missing. If this issue persists, try setting IDEPreferLogStreaming=YES in the active scheme actions environment variables.

Along with this warning, affected projects experience significantly slowed app launch times—the application may build successfully but take an unusually long time to load. This problem typically occurs across Xcode versions 15.3+ and seems inconsistent across machines, where some team members may experience the issue while others do not with identical SwiftUI projects.

Solutions

  1. Open your project in Xcode
  2. Go to ProductSchemeEdit Scheme...
  3. Select Run in the left sidebar
  4. Navigate to the Arguments tab
  5. In the "Environment Variables" section, click +
  6. Set these values:
    • Name: IDEPreferLogStreamING
    • Value: YES
shell
IDEPreferLogStreaming=YES
  1. Click Close to save changes
  2. Clean your build folder (ProductClean Build Folder)
  3. Run your project again

Why this works

This addresses Xcode's logging pipeline issues by preferring direct log streaming instead of buffered logging. It resolves both the warning message and associated performance degradation in most cases.

Alternative Environment Variables

For persistent cases, add these supplementary environment variables using the same scheme editor location:

  1. Name: IDELogRedirectionPolicy
    Value: oslogToStdio
  2. Name: OS_ACTIVITY_MODE
    Value: disable
shell
IDELogRedirectionPolicy=oslogToStdio
OS_ACTIVITY_MODE=disable

Note

OS_ACTIVITY_MODE=disable suppresses important console logs from Apple's systems. Use only as temporary workaround.

Clean Test Target Build Phases

For issues persisting after Xcode updates:

  1. Select your project in Project Navigator
  2. Choose affected test targets in the left panel (Unit/UI Tests)
  3. Go to Build PhasesCompile Sources
  4. Remove all source files not explicitly part of test cases:
    • Keep only *Tests.swift and *UITests.swift files
  5. In Copy Bundle Resources, remove non-essential resources
  6. Clean and rebuild project

Verifying the Fix

After applying solutions:

  1. The "Logging Error" warning should disappear
  2. App launch times should return to normal
  3. Console logs should appear consistently during debugging

For team projects:

  • Share scheme changes through version control by committing .xcodeproj/xcshareddata/xcschemes/*.xcscheme files
  • For environment variable differences, compare schemes using Xcode's Source Control diff tools

Prevention

To avoid recurrence:

  • Maintain lean test targets
  • Regularly clean build folders after Xcode updates (⌘⇧K)
  • Migrate to Xcode Cloud/Bots for consistent build environments

Conclusion

The "Failed to initialize logging system" error stems from Xcode's internal log handling conflicts. The primary solution—setting IDEPreferLogStreaming=YES—resolves most occurrences by changing logging mechanisms. For persistent cases, combine environment tweaks with test target cleanup. These solutions avoid drastic measures like OS/Xcode reinstallation while restoring normal development workflow performance.