OSLog is a unified logging system for the reading of historical data.

Posts under OSLog tag

166 Posts

Post

Replies

Boosts

Views

Activity

How can I make os_log write to a file on iOS?
I would like to record application log data in a file which iOS users can locate using the Files app and email to me in case of problems. Can I do this using the os_log functionality? The file path is defined as below: let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)         let documentsDirectory = paths[0]         let fileName = "\(Date()) CaptionEdit Logfile.txt"         let logFilePath = (documentsDirectory as NSString).appendingPathComponent(fileName)
1
0
3.1k
Sep ’22
Log to unified log from Python
Hi, I would like to log to the unified log from a Python program. I found (on Big Sur) that this can be done by writing to a UNIX domain socket at /var/run/syslog using UDP. The log records show up in the Console for Warning/Error levels, but it seems the standard log formats defined in RFC5424 or RFC3164 are not recognized. All fields except PRI go to the log message instead of being used as timestamp, hostname, etc. Two questions: What is the recommendation for logging to the unified log from Python? Is there a documentation for logging via Unix domain sockets, and if not, what format of the log message us supported for that?
8
1
2.1k
Sep ’22
Collecting iOS log after CI UI Tests on physical device
Hi, My application works with IoT devices, which is why I'm using a physical device for UI testing. The aplication logs a lot of useful informations, especially errors, which are common when working with third-party IoT platforms. Curreny I'm using logging library, which stores log data in the application's Documents directory, and I 'm able to download those data after testing using the 'ios-deply' tool in terminal.  It works quite well, but it's hard to read, and I would prefer to use Apple Logger instead, which is much cleaner. When using Logger, every UI test sets Logger's category as its own testCase.name passing it via launchEnvironment or directly from code in Unit tests. Then browsing every test's individual logs in .logarchive is simply by filtering by log category. My main problem is with collecting logarchive after testing, using: faslatne - collect logs only for simulators log collect- requires sudo. I'm running tests from Jenkins on a Mac as a node. cfgutil syslog, idevicesyslog - Only live logs OSLogStore - would be great to collect logs from every failed testCase and save them as a separate file in the application document directory, which then can be downloaded via terminal, but tests have no access to logs from the application. My questions are: Is there safe way to call "sudo log collect" from a Jenkins' Mac node? Access application/iPhone OSLogStore from test code? Access application/iPhone OSLogStore from a Macbook using a terminal? Maybe am I missing some other solutions? Thank you :)
0
0
2.0k
Aug ’22
Buffered Remote logging in Swift
I would like to implement remote logging in my Swift app for iOS. Log lines will need to be sent to a server so that I can analyse problems when the app is actually being used 'in the field'. This is the easy part. For user privacy, this might be limited to TestFlight versions of the app. The app is sometimes used in an area of poor or non-existent connectivity. So sendng the logs to our servers may fail. Therefore, I would like to see that the logs are buffered when connecting to our log server failed. The easiest way to buffer is in Memory (Array of 'LogEntry'), but when a bug we are trying to track involves a crash ... all memory is lost, so I would like the logs to be buffered on disk. Is there a way to do that? Perhaps using OSLog, or perhaps some other way? I understand that on iOS, the app does not (yet) have access to its logs. That would solve my problem, cos then I can read back the logs that I made and send them to the server when needed. I have thought about creating my own Log file, and (when there is a server connection) I read lines from the start of the file, and send that to the server. However, I have found no way to 'read and delete the first line of a file' without reading the whole file, and writing 'everything except the first line'. Seems like CoreData would not be such a bad idea, albeit a bit heavy for such a small task. Any suggestions? Any existing components that I can include in my project? (using cocoapods, SPM?) Thanks! Wouter
1
0
2.4k
Aug ’22
OSLogStore on watchOS
Hello. I'm developing a tightly coupled watchOS/iOS app. The customer needs to be able to write logs to text files, from both apps, in a hassle-free way. So I want to retrieve entries using OSLogStore, which works just fine on iOS: let store = try OSLogStore(scope: .currentProcessIdentifier) let pos = store.position(timeIntervalSinceEnd: -seconds) let entries = try store .getEntries(with: [], at: pos, matching: nil) .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == Bundle.main.bundleIdentifier! } .map { "[\($0.date.formatted())] [\($0.category)] \($0.composedMessage)" } .joined(separator: "\n") I've tried the same code on watchOS, with and without the filtering, but it always returns 0 entries. I can't find anything relating to this behavior in the documentation. So... does it just not work? Using a Watch SE 44mm and running watchOS 8.5 Thanks!
2
0
1.2k
Aug ’22
Unterstanding MacOS wifi logs
I'm using a Macbook Pro mid 2014 (Big Sur) and try to investigate wifi connection problems. My router (Fritz!Box 7590) shows in the logs that constantly every 10 minutes the Macbook has been logged of from the wifi network (802.11ac) and logged on again. E.g. it shows that at 10:04:30 the device has been logged off and then at 10:04:34 logged on again. I turned on wifi logging on my Macbook: wifi.log - https://developer.apple.com/forums/content/attachment/af953247-3676-411e-a4d8-24400ef31f5d Unfortunately I don't understand the contents of the wifi.log. May anybody give me a hint if there are specific log messages that indicate the reason for logging off and logging on again? Best regards
5
0
12k
Aug ’22
TaskGroup lockup with more than 7 tasks
Platform: macOS 12.4, MacBook Pro 2.3GHz Quad-Core i5, 16GB RAM I'm trying to read an OSLog concurrently because it is big and I don't need any of the data in order. Because the return from .getEntries is a sequence, the most efficient approach seems to be to iterate through. Iteration through the sequence from start to finish can take a long time so I thought I can split it up into days and concurrently process each day. I'm using a task group to do this and it works as long as the number of tasks is less than 8. When it works, I do get the result faster but not a lot faster. I guess there is a lot of overhead but actually it seems to be that my log file is dominated by the processing on 1 of the days. Ideally I want more concurrent tasks to break up the day into smaller blocks. But as soon as I try to create 8 or more tasks, I get a lockup with the following error posted to the console. enable_updates_common timed out waiting for updates to reenable Here are my tests. First - a pure iterative approach. No tasks. completion of this routine on my i5 quad core takes 229s    func scanLogarchiveIterative(url: URL) async {     do {       let timer = Date()               let logStore = try OSLogStore(url: url)       let last5days = logStore.position(timeIntervalSinceEnd: -3600*24*5)       let filteredEntries = try logStore.getEntries(at: last5days)               var processedEntries: [String] = []               for entry in filteredEntries {         processedEntries.append(entry.composedMessage)       }               print("Completed iterative scan in: ", timer.timeIntervalSinceNow)     } catch {             }   } Next is a concurrent approach using a TaskGroup which creates 5 child tasks. Completion takes 181s. Faster but the last day dominates so not a huge benefit as the most time is taken by a single task processing the last day.   func scanLogarchiveConcurrent(url: URL) async {     do {       let timer = Date()               var processedEntries: [String] = []               try await withThrowingTaskGroup(of: [String].self) { group in         let timestep = 3600*24         for logSectionStartPosition in stride(from: 0, to: -3600*24*5, by: -1*timestep) {           group.addTask {             let logStore = try OSLogStore(url: url)             let filteredEntries = try logStore.getEntries(at: logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition)))             var processedEntriesConcurrent: [String] = []             let endDate = logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition + timestep)).value(forKey: "date") as? Date             for entry in filteredEntries {               if entry.date > (endDate ?? Date()) {                 break               }               processedEntriesConcurrent.append(entry.composedMessage)             }             return processedEntriesConcurrent           }         }                   for try await processedEntriesConcurrent in group {           print("received task completion")           processedEntries.append(contentsOf: processedEntriesConcurrent)         }       }               print("Completed concurrent scan in: ", timer.timeIntervalSinceNow)             } catch {             }   } If I split this further to concurrently process half days, then the app locks up. The console periodically prints enable_updates_common timed out waiting for updates to reenable If I pause the debugger, it seems like there is a wait on a semaphore which must be internal to the concurrent framework?    func scanLogarchiveConcurrentManyTasks(url: URL) async {     do {       let timer = Date()               var processedEntries: [String] = []               try await withThrowingTaskGroup(of: [String].self) { group in         let timestep = 3600*12         for logSectionStartPosition in stride(from: 0, to: -3600*24*5, by: -1*timestep) {           group.addTask {             let logStore = try OSLogStore(url: url)             let filteredEntries = try logStore.getEntries(at: logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition)))             var processedEntriesConcurrent: [String] = []             let endDate = logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition + timestep)).value(forKey: "date") as? Date             for entry in filteredEntries {               if entry.date > (endDate ?? Date()) {                 break               }               processedEntriesConcurrent.append(entry.composedMessage)             }             return processedEntriesConcurrent           }         }                   for try await processedEntriesConcurrent in group {           print("received task completion")           processedEntries.append(contentsOf: processedEntriesConcurrent)         }       }               print("Completed concurrent scan in: ", timer.timeIntervalSinceNow)             } catch {             }   } I read that it may be possible to get more insight into concurrency issue by setting the following environment: LIBDISPATCH_COOPERATIVE_POOL_STRICT 1 This stops the lockup but it is because each task is run sequentially so there is no benefit from concurrency anymore. I cannot see where to go next apart from accept the linear processing time. It also feels like doing any concurrency (even if under 8 tasks) is risky as there is no documentation to suggest that is a limit. Could it be that concurrently processing the sequence from OSLog .getEntries is not suitable for concurrent access and shouldn't be done? Again, I don't see any documentation to suggest this is the case. Finally, the processing of each entry is so light that there is little benefit to offloading just the processing to other tasks. The time taken seems to be purely dominated by iterating the sequence. In reality I do use a predicate in .getEntries which helps a bit but its not enough and concurrency would still be valuable if I could process 1 hour blocks concurrently.
2
0
2.7k
Jun ’22
Kernel DriverKit log subsystem
I'm debugging a USB DriverKit driver, and noticed the os_log messages during the kernel verification checks do not have a subsystem (not my driver's logging): { "traceID" : 44303244788367364, "eventMessage" : "DK: G600Driver-0x1002dd073: family entitlements check failed", "eventType" : "logEvent", "source" : null, "formatString" : "DK: %s-0x%qx: family entitlements check failed\n", "activityIdentifier" : 0, "subsystem" : "", "category" : "", "threadID" : 2655768, "senderImageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2", "backtrace" : { "frames" : [ { "imageOffset" : 9007231, "imageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2" } ] }, "bootUUID" : "", "processImagePath" : "\/kernel", "timestamp" : "2022-06-14 01:57:51.171906-0700", "senderImagePath" : "\/kernel", "machTimestamp" : 281599031530198, "messageType" : "Default", "processImageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2", "processID" : 0, "senderProgramCounter" : 9007231, "parentActivityIdentifier" : 0, "timezoneName" : "" } Is there a recommended way (other than substring matching on the driver name) to create a predicate for filtering the log to messages relevant to my driver? Thanks.
2
0
1.4k
Jun ’22
thread_policy_set(1) returned 46
Hi there, Recently we have been seeing thread_policy_set(1) returned 46 flooding our log output. We tracked down that the flood of this is coming from a separate library whom we've contacted. They mentioned that this is a Apple internal message that comes up in the library's deadlock detector. The proposed solution was to use OS_ACTIVITY_MODE env var to hide the logs as suggested from the post on StackOverflow.. I tried all suggestions from that StackOverflow post, which were able to hide other system logs generated from Apple but it specifically did not hide the thread_policy_set(1) returned 46 What I am hoping to understand is: Why does this message come up? I see that the documentation for this on Apple's docs is very limited. Is this message's visibility controllable via a separate variable in project settings outside of modifying settings for all logs? As a last resort, how can I disable only this log message? Thank you!
19
0
4.6k
May ’22
Logging from NetworkExtension
I'm debugging very rarely occuring problem in my NetworkExtension. For this I rely on logs being saved by OSLog: import os.log ... os_log("[TAG] %{public}s", log: OSLog.default, type: type, String(describing: msg)) After I download logs from the phone using log collect on my mac, I can see, that only logs made while phone was unlocked are persisted. If I filter logs for my process, I can see that something is going on, as a lot of other logs from my process are saved (like the ones with categories tcp, connection, boringssl, etc.), but not my custom logs made with os_log. My logs appear only around the time I unlock the phone. Is it expected behaviour? Can I make it log all the time without exceptions?
5
0
2.9k
Mar ’22
how to collect logs from command line
I'm trying to collect logs on my mac from my app running on iPhone, but I always get an error. I use log collect as such: % sudo log collect --device --output log.logarchive --last 1m Archive successfully written to log.logarchive % sudo log show --archive log.logarchive/ log: Could not open log archive: The log archive is corrupt or incomplete and cannot be read so log show always claims the logs create by log collect are corrupt. I'm on maces monterey and iOS 15.3, and solution / tip? thanks
2
1
3.3k
Mar ’22
LogRocket screen recording and Apple
Does anyone here have experience with LogRocket in an iOS app, specifically the screen recording capabilities? I'm working on a project in which LogRocket has come up as a "desired" addition. They are really interested in the screen recording capability. According to LogRocket, they have an agreement with Apple whereby apps don't have to notify users about screen recording if they accept a "general" analytics question. This doesn't feel right to me, particularly given Apple's privacy focus. If you're using LogRocket, how do you handle this?
1
0
1.8k
Mar ’22
Using OSLogStore to fetch app logs across restarts
I was delighted to see that OSLogStore finally works on iOS 15+, so that I could enable our users to share the logs with us within our app, without having to roll our own custom logging. However, from what I can see, this functionality is still essentially crippled. Is there any way to fetch logs across app restarts? (ie app crashes, then the user re-opens and we want to upload those logs). As far as I can see .currentProcessIdentifier will only enable us to access logs from the current process. If not - what is everyone doing to make this actually useful? are we still stuck with using third party logging mechanisms / rolling our own? Many thanks
1
0
1.4k
Feb ’22
Did syslog break for CoreAudio/MIDI server plugins?
The very little and outdated 'documentation' shared by Apple about CoreAudio and CoreMIDI server plugins suggested to use syslog for logging. At least since Bug Sur syslog doesn't end up anywhere. (So, while you seem to think its OK to not document your APIs you could at least remove not working APIs then! Not to do so causes unnecessary and frustrating bug hunting?) Should we replace syslog by unified logging? For debugging purpose only our plugins write to our own log files. Where can I find suitable locations? Where is this documented? Thanks, hagen.
2
0
1.3k
Jan ’22
Console is not loading .logarchive files from device
Hi I have watched this video https://developer.apple.com/wwdc20/10168 and tried to implement Logger in my application. Then I've tried to generate .logarchive file from my iPhone device using this command (as it was mentioned in the video): sudo log collect --device --start '2021-09-07 10:00:00' --output logTest.logarchive where the result was: Archive successfully written to logTest.logarchive However, when I double-click over this file it opens the Console.app but then it stays infinitely loading the .logarchive. Some notes: The file size is about 150Mb, so I believe is not related with this. Am I doing something wrong? Can you please help me? Thanks in advance
2
0
1.2k
Jan ’22
Is the Console app an app that runs on iOS that I can get straight from the App Store?
Would someone explain something about this content I got from this URL to Apple documentation? Logging ”You view log messages using the Console app, log command-line tool, or Xcode debug console. You can also access log messages programmatically using the OSLogframework.” I’m not sure what Console app runs on. Is that an app on macOS? I’m not really sure what to ask really. I’m looking for a way to get debug data from people using my app who download it from the App Store, so they won’t be using TestFlight. I did a search on Google but didn’t find what I needed to know. I’m trying to connect to the App Store on my iPhone, but it’s not able to connect. That seems to happen often for some reason. I wonder if this is talking about the Console app that I’m wondering about? https://help.dayoneapp.com/en/articles/470117-using-ios-console
1
0
3.7k
Jan ’22
Can't see crash logs
I'm developing a Mac OS application. I can see the following error message when I run the application. "You do not have permission to open the application" If the SIP is disable, the crash report is stored in "users\username\Library\Logs\DiagnosticReports". But if the SIP is enable, I cannot see the log in same folder. Do you know where the log is stored? Mac OS 11.2.2
0
0
631
Nov ’21
How can I make os_log write to a file on iOS?
I would like to record application log data in a file which iOS users can locate using the Files app and email to me in case of problems. Can I do this using the os_log functionality? The file path is defined as below: let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)         let documentsDirectory = paths[0]         let fileName = "\(Date()) CaptionEdit Logfile.txt"         let logFilePath = (documentsDirectory as NSString).appendingPathComponent(fileName)
Replies
1
Boosts
0
Views
3.1k
Activity
Sep ’22
Log to unified log from Python
Hi, I would like to log to the unified log from a Python program. I found (on Big Sur) that this can be done by writing to a UNIX domain socket at /var/run/syslog using UDP. The log records show up in the Console for Warning/Error levels, but it seems the standard log formats defined in RFC5424 or RFC3164 are not recognized. All fields except PRI go to the log message instead of being used as timestamp, hostname, etc. Two questions: What is the recommendation for logging to the unified log from Python? Is there a documentation for logging via Unix domain sockets, and if not, what format of the log message us supported for that?
Replies
8
Boosts
1
Views
2.1k
Activity
Sep ’22
Collecting iOS log after CI UI Tests on physical device
Hi, My application works with IoT devices, which is why I'm using a physical device for UI testing. The aplication logs a lot of useful informations, especially errors, which are common when working with third-party IoT platforms. Curreny I'm using logging library, which stores log data in the application's Documents directory, and I 'm able to download those data after testing using the 'ios-deply' tool in terminal.  It works quite well, but it's hard to read, and I would prefer to use Apple Logger instead, which is much cleaner. When using Logger, every UI test sets Logger's category as its own testCase.name passing it via launchEnvironment or directly from code in Unit tests. Then browsing every test's individual logs in .logarchive is simply by filtering by log category. My main problem is with collecting logarchive after testing, using: faslatne - collect logs only for simulators log collect- requires sudo. I'm running tests from Jenkins on a Mac as a node. cfgutil syslog, idevicesyslog - Only live logs OSLogStore - would be great to collect logs from every failed testCase and save them as a separate file in the application document directory, which then can be downloaded via terminal, but tests have no access to logs from the application. My questions are: Is there safe way to call "sudo log collect" from a Jenkins' Mac node? Access application/iPhone OSLogStore from test code? Access application/iPhone OSLogStore from a Macbook using a terminal? Maybe am I missing some other solutions? Thank you :)
Replies
0
Boosts
0
Views
2.0k
Activity
Aug ’22
Buffered Remote logging in Swift
I would like to implement remote logging in my Swift app for iOS. Log lines will need to be sent to a server so that I can analyse problems when the app is actually being used 'in the field'. This is the easy part. For user privacy, this might be limited to TestFlight versions of the app. The app is sometimes used in an area of poor or non-existent connectivity. So sendng the logs to our servers may fail. Therefore, I would like to see that the logs are buffered when connecting to our log server failed. The easiest way to buffer is in Memory (Array of 'LogEntry'), but when a bug we are trying to track involves a crash ... all memory is lost, so I would like the logs to be buffered on disk. Is there a way to do that? Perhaps using OSLog, or perhaps some other way? I understand that on iOS, the app does not (yet) have access to its logs. That would solve my problem, cos then I can read back the logs that I made and send them to the server when needed. I have thought about creating my own Log file, and (when there is a server connection) I read lines from the start of the file, and send that to the server. However, I have found no way to 'read and delete the first line of a file' without reading the whole file, and writing 'everything except the first line'. Seems like CoreData would not be such a bad idea, albeit a bit heavy for such a small task. Any suggestions? Any existing components that I can include in my project? (using cocoapods, SPM?) Thanks! Wouter
Replies
1
Boosts
0
Views
2.4k
Activity
Aug ’22
OSLogStore on watchOS
Hello. I'm developing a tightly coupled watchOS/iOS app. The customer needs to be able to write logs to text files, from both apps, in a hassle-free way. So I want to retrieve entries using OSLogStore, which works just fine on iOS: let store = try OSLogStore(scope: .currentProcessIdentifier) let pos = store.position(timeIntervalSinceEnd: -seconds) let entries = try store .getEntries(with: [], at: pos, matching: nil) .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == Bundle.main.bundleIdentifier! } .map { "[\($0.date.formatted())] [\($0.category)] \($0.composedMessage)" } .joined(separator: "\n") I've tried the same code on watchOS, with and without the filtering, but it always returns 0 entries. I can't find anything relating to this behavior in the documentation. So... does it just not work? Using a Watch SE 44mm and running watchOS 8.5 Thanks!
Replies
2
Boosts
0
Views
1.2k
Activity
Aug ’22
Unterstanding MacOS wifi logs
I'm using a Macbook Pro mid 2014 (Big Sur) and try to investigate wifi connection problems. My router (Fritz!Box 7590) shows in the logs that constantly every 10 minutes the Macbook has been logged of from the wifi network (802.11ac) and logged on again. E.g. it shows that at 10:04:30 the device has been logged off and then at 10:04:34 logged on again. I turned on wifi logging on my Macbook: wifi.log - https://developer.apple.com/forums/content/attachment/af953247-3676-411e-a4d8-24400ef31f5d Unfortunately I don't understand the contents of the wifi.log. May anybody give me a hint if there are specific log messages that indicate the reason for logging off and logging on again? Best regards
Replies
5
Boosts
0
Views
12k
Activity
Aug ’22
TaskGroup lockup with more than 7 tasks
Platform: macOS 12.4, MacBook Pro 2.3GHz Quad-Core i5, 16GB RAM I'm trying to read an OSLog concurrently because it is big and I don't need any of the data in order. Because the return from .getEntries is a sequence, the most efficient approach seems to be to iterate through. Iteration through the sequence from start to finish can take a long time so I thought I can split it up into days and concurrently process each day. I'm using a task group to do this and it works as long as the number of tasks is less than 8. When it works, I do get the result faster but not a lot faster. I guess there is a lot of overhead but actually it seems to be that my log file is dominated by the processing on 1 of the days. Ideally I want more concurrent tasks to break up the day into smaller blocks. But as soon as I try to create 8 or more tasks, I get a lockup with the following error posted to the console. enable_updates_common timed out waiting for updates to reenable Here are my tests. First - a pure iterative approach. No tasks. completion of this routine on my i5 quad core takes 229s    func scanLogarchiveIterative(url: URL) async {     do {       let timer = Date()               let logStore = try OSLogStore(url: url)       let last5days = logStore.position(timeIntervalSinceEnd: -3600*24*5)       let filteredEntries = try logStore.getEntries(at: last5days)               var processedEntries: [String] = []               for entry in filteredEntries {         processedEntries.append(entry.composedMessage)       }               print("Completed iterative scan in: ", timer.timeIntervalSinceNow)     } catch {             }   } Next is a concurrent approach using a TaskGroup which creates 5 child tasks. Completion takes 181s. Faster but the last day dominates so not a huge benefit as the most time is taken by a single task processing the last day.   func scanLogarchiveConcurrent(url: URL) async {     do {       let timer = Date()               var processedEntries: [String] = []               try await withThrowingTaskGroup(of: [String].self) { group in         let timestep = 3600*24         for logSectionStartPosition in stride(from: 0, to: -3600*24*5, by: -1*timestep) {           group.addTask {             let logStore = try OSLogStore(url: url)             let filteredEntries = try logStore.getEntries(at: logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition)))             var processedEntriesConcurrent: [String] = []             let endDate = logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition + timestep)).value(forKey: "date") as? Date             for entry in filteredEntries {               if entry.date > (endDate ?? Date()) {                 break               }               processedEntriesConcurrent.append(entry.composedMessage)             }             return processedEntriesConcurrent           }         }                   for try await processedEntriesConcurrent in group {           print("received task completion")           processedEntries.append(contentsOf: processedEntriesConcurrent)         }       }               print("Completed concurrent scan in: ", timer.timeIntervalSinceNow)             } catch {             }   } If I split this further to concurrently process half days, then the app locks up. The console periodically prints enable_updates_common timed out waiting for updates to reenable If I pause the debugger, it seems like there is a wait on a semaphore which must be internal to the concurrent framework?    func scanLogarchiveConcurrentManyTasks(url: URL) async {     do {       let timer = Date()               var processedEntries: [String] = []               try await withThrowingTaskGroup(of: [String].self) { group in         let timestep = 3600*12         for logSectionStartPosition in stride(from: 0, to: -3600*24*5, by: -1*timestep) {           group.addTask {             let logStore = try OSLogStore(url: url)             let filteredEntries = try logStore.getEntries(at: logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition)))             var processedEntriesConcurrent: [String] = []             let endDate = logStore.position(timeIntervalSinceEnd: TimeInterval(logSectionStartPosition + timestep)).value(forKey: "date") as? Date             for entry in filteredEntries {               if entry.date > (endDate ?? Date()) {                 break               }               processedEntriesConcurrent.append(entry.composedMessage)             }             return processedEntriesConcurrent           }         }                   for try await processedEntriesConcurrent in group {           print("received task completion")           processedEntries.append(contentsOf: processedEntriesConcurrent)         }       }               print("Completed concurrent scan in: ", timer.timeIntervalSinceNow)             } catch {             }   } I read that it may be possible to get more insight into concurrency issue by setting the following environment: LIBDISPATCH_COOPERATIVE_POOL_STRICT 1 This stops the lockup but it is because each task is run sequentially so there is no benefit from concurrency anymore. I cannot see where to go next apart from accept the linear processing time. It also feels like doing any concurrency (even if under 8 tasks) is risky as there is no documentation to suggest that is a limit. Could it be that concurrently processing the sequence from OSLog .getEntries is not suitable for concurrent access and shouldn't be done? Again, I don't see any documentation to suggest this is the case. Finally, the processing of each entry is so light that there is little benefit to offloading just the processing to other tasks. The time taken seems to be purely dominated by iterating the sequence. In reality I do use a predicate in .getEntries which helps a bit but its not enough and concurrency would still be valuable if I could process 1 hour blocks concurrently.
Replies
2
Boosts
0
Views
2.7k
Activity
Jun ’22
Kernel DriverKit log subsystem
I'm debugging a USB DriverKit driver, and noticed the os_log messages during the kernel verification checks do not have a subsystem (not my driver's logging): { "traceID" : 44303244788367364, "eventMessage" : "DK: G600Driver-0x1002dd073: family entitlements check failed", "eventType" : "logEvent", "source" : null, "formatString" : "DK: %s-0x%qx: family entitlements check failed\n", "activityIdentifier" : 0, "subsystem" : "", "category" : "", "threadID" : 2655768, "senderImageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2", "backtrace" : { "frames" : [ { "imageOffset" : 9007231, "imageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2" } ] }, "bootUUID" : "", "processImagePath" : "\/kernel", "timestamp" : "2022-06-14 01:57:51.171906-0700", "senderImagePath" : "\/kernel", "machTimestamp" : 281599031530198, "messageType" : "Default", "processImageUUID" : "198748B0-2858-345A-957A-45C9ACB4C2F2", "processID" : 0, "senderProgramCounter" : 9007231, "parentActivityIdentifier" : 0, "timezoneName" : "" } Is there a recommended way (other than substring matching on the driver name) to create a predicate for filtering the log to messages relevant to my driver? Thanks.
Replies
2
Boosts
0
Views
1.4k
Activity
Jun ’22
Logger API iOS14
I am trying to use the Logger api instead of CocoaLumberjack. In the WWDC 2020 video it states that log messages will display in the Xcode debug console as well as the device logs. However, I cannot see any of these messages in Xcode. Does anyone have any insight on this?
Replies
3
Boosts
0
Views
2.0k
Activity
May ’22
thread_policy_set(1) returned 46
Hi there, Recently we have been seeing thread_policy_set(1) returned 46 flooding our log output. We tracked down that the flood of this is coming from a separate library whom we've contacted. They mentioned that this is a Apple internal message that comes up in the library's deadlock detector. The proposed solution was to use OS_ACTIVITY_MODE env var to hide the logs as suggested from the post on StackOverflow.. I tried all suggestions from that StackOverflow post, which were able to hide other system logs generated from Apple but it specifically did not hide the thread_policy_set(1) returned 46 What I am hoping to understand is: Why does this message come up? I see that the documentation for this on Apple's docs is very limited. Is this message's visibility controllable via a separate variable in project settings outside of modifying settings for all logs? As a last resort, how can I disable only this log message? Thank you!
Replies
19
Boosts
0
Views
4.6k
Activity
May ’22
When does UAL cleans the log files?
UAL (Unified Access Logging) system saves every log into files. But when does those files expire? It cannot grow forever.
Replies
1
Boosts
0
Views
1.2k
Activity
May ’22
Logging from NetworkExtension
I'm debugging very rarely occuring problem in my NetworkExtension. For this I rely on logs being saved by OSLog: import os.log ... os_log("[TAG] %{public}s", log: OSLog.default, type: type, String(describing: msg)) After I download logs from the phone using log collect on my mac, I can see, that only logs made while phone was unlocked are persisted. If I filter logs for my process, I can see that something is going on, as a lot of other logs from my process are saved (like the ones with categories tcp, connection, boringssl, etc.), but not my custom logs made with os_log. My logs appear only around the time I unlock the phone. Is it expected behaviour? Can I make it log all the time without exceptions?
Replies
5
Boosts
0
Views
2.9k
Activity
Mar ’22
how to collect logs from command line
I'm trying to collect logs on my mac from my app running on iPhone, but I always get an error. I use log collect as such: % sudo log collect --device --output log.logarchive --last 1m Archive successfully written to log.logarchive % sudo log show --archive log.logarchive/ log: Could not open log archive: The log archive is corrupt or incomplete and cannot be read so log show always claims the logs create by log collect are corrupt. I'm on maces monterey and iOS 15.3, and solution / tip? thanks
Replies
2
Boosts
1
Views
3.3k
Activity
Mar ’22
LogRocket screen recording and Apple
Does anyone here have experience with LogRocket in an iOS app, specifically the screen recording capabilities? I'm working on a project in which LogRocket has come up as a "desired" addition. They are really interested in the screen recording capability. According to LogRocket, they have an agreement with Apple whereby apps don't have to notify users about screen recording if they accept a "general" analytics question. This doesn't feel right to me, particularly given Apple's privacy focus. If you're using LogRocket, how do you handle this?
Replies
1
Boosts
0
Views
1.8k
Activity
Mar ’22
Using OSLogStore to fetch app logs across restarts
I was delighted to see that OSLogStore finally works on iOS 15+, so that I could enable our users to share the logs with us within our app, without having to roll our own custom logging. However, from what I can see, this functionality is still essentially crippled. Is there any way to fetch logs across app restarts? (ie app crashes, then the user re-opens and we want to upload those logs). As far as I can see .currentProcessIdentifier will only enable us to access logs from the current process. If not - what is everyone doing to make this actually useful? are we still stuck with using third party logging mechanisms / rolling our own? Many thanks
Replies
1
Boosts
0
Views
1.4k
Activity
Feb ’22
Did syslog break for CoreAudio/MIDI server plugins?
The very little and outdated 'documentation' shared by Apple about CoreAudio and CoreMIDI server plugins suggested to use syslog for logging. At least since Bug Sur syslog doesn't end up anywhere. (So, while you seem to think its OK to not document your APIs you could at least remove not working APIs then! Not to do so causes unnecessary and frustrating bug hunting?) Should we replace syslog by unified logging? For debugging purpose only our plugins write to our own log files. Where can I find suitable locations? Where is this documented? Thanks, hagen.
Replies
2
Boosts
0
Views
1.3k
Activity
Jan ’22
Does TestFlight show what Logger logs from my app?
Am I able to see what Logger logs from my app when it's running on a device belonging to an external tester if my app doesn't crash? Am I able to see the logs if my app does crash? I am using Swift with Xcode for iOS.
Replies
2
Boosts
0
Views
9.7k
Activity
Jan ’22
Console is not loading .logarchive files from device
Hi I have watched this video https://developer.apple.com/wwdc20/10168 and tried to implement Logger in my application. Then I've tried to generate .logarchive file from my iPhone device using this command (as it was mentioned in the video): sudo log collect --device --start '2021-09-07 10:00:00' --output logTest.logarchive where the result was: Archive successfully written to logTest.logarchive However, when I double-click over this file it opens the Console.app but then it stays infinitely loading the .logarchive. Some notes: The file size is about 150Mb, so I believe is not related with this. Am I doing something wrong? Can you please help me? Thanks in advance
Replies
2
Boosts
0
Views
1.2k
Activity
Jan ’22
Is the Console app an app that runs on iOS that I can get straight from the App Store?
Would someone explain something about this content I got from this URL to Apple documentation? Logging ”You view log messages using the Console app, log command-line tool, or Xcode debug console. You can also access log messages programmatically using the OSLogframework.” I’m not sure what Console app runs on. Is that an app on macOS? I’m not really sure what to ask really. I’m looking for a way to get debug data from people using my app who download it from the App Store, so they won’t be using TestFlight. I did a search on Google but didn’t find what I needed to know. I’m trying to connect to the App Store on my iPhone, but it’s not able to connect. That seems to happen often for some reason. I wonder if this is talking about the Console app that I’m wondering about? https://help.dayoneapp.com/en/articles/470117-using-ios-console
Replies
1
Boosts
0
Views
3.7k
Activity
Jan ’22
Can't see crash logs
I'm developing a Mac OS application. I can see the following error message when I run the application. "You do not have permission to open the application" If the SIP is disable, the crash report is stored in "users\username\Library\Logs\DiagnosticReports". But if the SIP is enable, I cannot see the log in same folder. Do you know where the log is stored? Mac OS 11.2.2
Replies
0
Boosts
0
Views
631
Activity
Nov ’21