Xcode 15 structured logging not working for existing project

Using the latest Xcode 15 Beta 7: In an existing project, I can't get structured logging to work as described. For new projects, it works fine but I must have some setting or value in an existing project that prevents it from working.

My simple text case:

In an existing project file:

@main
struct LuarasBooksApp: App {
    var body: some Scene {
        WindowGroup {
            Text("hi")
                .onAppear {
                    Logger(subsystem: "test", category: "test").error("help me")
                }
        }
    }
}

The debug console looks like this:

That same code in a new project for the same Xcode 15 Beta 7 looks correct:

Are there any settings, variables, etc... related to logging or the console that might cause this difference? In the existing project it makes no difference to toggle the various metadata options on and off.

Thanks!

Answered by CyberNate in 762710022

Great!! Yes, structured logging does depend on newer OS features and does therefore require iOS 17.0+ to function with structured logging. That also includes simulators so you will need to be on newer simulators.

Thanks!

It looks like there may be an environment variable set in your scheme. Can you check if something is there? Specifically OS_ACTIVITY_DT_MODE=1 or some other value? This will request Xcode use the old logging system and redirect os_log to stderr like this.

Thank you for the reply! I looked in my scheme and there are no environment variables set or extra arguments passed on launch. I even created a new default scheme to test and still have the same results.

I do think there is some environment or other value set somewhere that is causing this but it isn't obvious to me where it might be. I tried removing all derived data as well but no luck.

More testing shows that if I switch to a different simulator with iOS 17 the structured logging does work as expected for the same project. Does this feature also require iOS 17? Or does it need a different configuration to work with iOS 16? Everything I've seen written about it only mentions Xcode 15 and nothing about a specific iOS version.

Accepted Answer

Great!! Yes, structured logging does depend on newer OS features and does therefore require iOS 17.0+ to function with structured logging. That also includes simulators so you will need to be on newer simulators.

Thanks!

Hi @nathanfusselman I'm also running Xcode 15 Beta 7 and structured logging doesn't seem to be working for me either. I'm using an iOS 17 simulator and I remember structured logging working just fine in the previous beta versions.

Xcode 15 structured logging not working for existing project
 
 
Q