Skip to content

macOS 26 system log redirection reports all content as <private> #150644

@freakboy3742

Description

@freakboy3742

Bug report

Bug description:

#127592 added support for redirecting stdout/stderr to the Apple System Log when running on macOS and iOS, using the os_log() method.

However macOS 26 has slightly altered the operation the system log. All "dynamic" strings (that is, any string that is constructed at runtime, rather than being a statically defined in source code), appears in the system log as <private>. All Python logging messages will be dynamic by definition, so this change renders Python system logging useless on macOS 26.

While the private/public message split existed on previous versions of macOS, the default behavior of the system logger allowed dynamic messages to be viewed.

The fix is to format the string using os_log(..., "%{public}s", ....), rather than a simple "%s" definition.

An immediate workaround is to apply a custom logging profile. Save the following as a file named private-logging.mobileconfig

Contents of `private-logging.mobileconfig`
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PayloadContent</key>
    <array>
        <dict>
            <key>PayloadDisplayName</key>
            <string>ManagedClient logging</string>
            <key>PayloadEnabled</key>
            <true/>
            <key>PayloadIdentifier</key>
            <string>com.apple.logging.ManagedClient.1</string>
            <key>PayloadType</key>
            <string>com.apple.system.logging</string>
            <key>PayloadUUID</key>
            <string>ED5DE307-A5FC-434F-AD88-187677F02222</string>
            <key>PayloadVersion</key>
            <integer>1</integer>
            <key>System</key>
            <dict>
                <key>Enable-Private-Data</key>
                <true/>
            </dict>
        </dict>
    </array>
    <key>PayloadDescription</key>
    <string>Enable Unified Log Private Data logging</string>
    <key>PayloadDisplayName</key>
    <string>Enable Unified Log Private Data</string>
    <key>PayloadIdentifier</key>
    <string>C510208B-AD6E-4121-A945-E397B61CACCF</string>
    <key>PayloadRemovalDisallowed</key>
    <false/>
    <key>PayloadScope</key>
    <string>System</string>
    <key>PayloadType</key>
    <string>Configuration</string>
    <key>PayloadUUID</key>
    <string>D30C25BD-E0C1-44C8-830A-964F27DAD4BA</string>
    <key>PayloadVersion</key>
    <integer>1</integer>
</dict>
</plist>

Double click on the file in finder, then navigate to the "Device Management" tab in system settings, and approve the "Enable Unified Log Private Data logging" profile.

Applying this profile requires admin permissions, and it applies to all logging, so it's not really appropriate as a general solution.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

3.13bugs and security fixes3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixesOS-iosOS-mactype-bugAn unexpected behavior, bug, or error
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions