9 Replies
      Latest reply on Jan 11, 2019 1:22 AM by eskimo
      TheDarkKnight Level 1 Level 1 (10 points)

        I have a Swift 3 Cocoa application that uses Apple's Unified Logging, like this: -

         

            import os
        
            class MyClass
            {
                @available(OSX 10.12, *)
                static let scribe = OSLog(subsystem: "com.mycompany.myapp", category: "myapp")
        
                func SomeFunction(){
          
                    if #available(OSX 10.12, *){
                        os_log("Test Error Message", log: MyClass.scribe, type: .error)
                    }
        
                    if #available(OSX 10.12, *){
                        os_log("Test Info Message", log: MyClass.scribe, type: .info)
                    }
        
                    if #available(OSX 10.12, *){
                        os_log("Test Debug Message", log: MyClass.scribe, type: .debug)
                    }
                }
            }
        
        
        

         

         

        Within the Console application, both Include Info Messages and Include Debug Messages are turned on.

         

        When os_log is called, only the error type message is visible in the Console application.

        Using Terminal, with the command, all message types are visible in the Terminal output: -

         

        sudo log stream --level debug

         

        I've tried running the Console app as root, via sudo from the command line and the same issue occurs; no debug or info messages can be seen, even though they're set to being turned on under the Action menu.


        Setting system-wide logging to be debug, has no effect on the Console application output:

        sudo log config --mode level:debug
        
        
        

         

        Please can someone tell me what I'm missing and how can I view debug and info messages in the Console application?

        • Re: Console app not showing info and debug logs
          eskimo Apple Staff Apple Staff (10,445 points)

          Well, that’s interesting.  I can reproduce this problem on my main 10.12.5 machine.  Which is weird because I definitely remember seeing those messages on earlier versions of 10.12.  So I fired up some VMs and found the following:

          • Console shows info messages on the VM’s 10.12 snapshot

          • Console doesn’t show info messages on its 10.12.5 snapshot

          I suspect that this is a known bug (r. 30733532) that’s reported fixed in the current 10.13 beta.  Please give it a try there.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Console app not showing info and debug logs
              TheDarkKnight Level 1 Level 1 (10 points)

              Hi Quinn,

               

              Thanks for getting back to me, I've never had Unified Logging working correctly since it was first introduced, at which time, it only showed logs in the console if we were logging out the stream in the Terminal at the same time.

               

              As requested, I tried on 10.13 (17A306f) with a daemon application I'm developing. When the daemon was first loaded, after installing the application via a pkg, it failed to show any logs. I stopped the daemon (launchctl unload), ran the application from the command line and Console started working as expected. Following that, I restarted the daemon (launchctl load) and it continued working correctly. We'll continue testing around the initial install and let you know if we think there's an issue there and will file a report accordingly.

               

              Should I file a report bug for 10.12.5, or is it likely to just be a repeat?

               

              One other question, the daemon is written in Swift 3 and we still see 'private', printed even though we're using the public attributes  %{public}s or %{public}@. Can you tell me if this should work now, in Swift?  If I recall correctly, it didn't when Unified Logging was first announced.

               

              Thanks.

                • Re: Console app not showing info and debug logs
                  eskimo Apple Staff Apple Staff (10,445 points)

                  Should I file a report bug for 10.12.5, or is it likely to just be a repeat?

                  At this point I doubt there’s much benefit to filing a 10.12.x bug for this.

                  in Swift 3 … we still see 'private', printed even though we're using the public attributes  %{public}s or %{public}@. Can you tell me if this should work now, in Swift?

                  I believe this is still broken )-:  It’s definitely worth filing a bug about this one though; it’ll probably get dup’d to an existing bug (r. 33376006) but it’d be helpful to record your specific circumstances (for example, the fact you’re working on macOS and that you’ve tested it on the current 10.13 beta).

                  Please post your bug number, just for the record.

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"

              • Re: Console app not showing info and debug logs
                nteissler Level 1 Level 1 (0 points)

                I'm running 10.14 Beta (18A336e) and was seeing similar behavior, but was able to view the debug messages in the console when I also used the persist option

                 

                sudo log config --mode "level:debug,persist:debug" --subsystem com.myapp.myfancylog --category myCategory

                 

                This only worked for macOS apps, both command line and cocoa apps. iPhone logs I could never get to show the debug logs anywhere but the xcode console. As another note, I'm not sure if setting the category made any difference.

                  • Re: Console app not showing info and debug logs
                    marekfort Level 1 Level 1 (0 points)

                    This should work:

                     

                    xcrun simctl spawn booted log stream --debug --predicate 'subsystem == "com.example.yourapp"'

                     

                    But yeah, the issue still persists and it's quite a shame. I am not sure if a bug has been filed for this, so should I create one? I am quite honestly amazed that this still seems to be an issue.

                      • Re: Console app not showing info and debug logs
                        eskimo Apple Staff Apple Staff (10,445 points)

                        But yeah, the issue still persists and it's quite a shame.

                        What issue are you referring to here?  The original issue that started this thread — that is, the inability so see Info and Debug log entries in the Console app (r. 30733532) — was fixed years ago.  And the issue reported by nteissler was in a 10.14 beta, and my experience is that it was fixed before 10.14 shipped.

                        Share and Enjoy

                        Quinn “The Eskimo!”
                        Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                        let myEmail = "eskimo" + "1" + "@apple.com"