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

Posts under OSLog tag

166 Posts

Post

Replies

Boosts

Views

Activity

CarbonAPI DebugStr() deprecation
Howdy all, I'm in the process of eliminating some compiler warnings in a legacy project, and have come across a compiler warning for the usage of extern void DebugStr(ConstStr255Param debuggerMsg), defined in MacTypes.h as part of CarbonCore-769-1. I've looked through Apple's documentation for Cocoa and the MacOSX13.1 SDK but haven't found any leads on what I could/should replace it with. Can anyone point me in the right direction? Thanks!!
4
0
919
Sep ’23
Cannot get incremental logs from OSLogStore
Hello folks, I would like to incrementally retrieve logs of my iOS App from the Unified Logging System using OSLogStore. First I initialize the store store = try OSLogStore(scope: .currentProcessIdentifier) Second I set a position from which I want the logs using either : position = store.position(timeIntervalSinceLatestBoot: 0) // to get the logs from the launch of the App position = store.position(date: Date().addingTimeInterval(-10)) // to get the logs of the last 10 seconds Third I get the entries in the store from the position store.getEntries(at: position) Issue Whatever the position I set using from OSLogStore: position(timeIntervalSinceLatestBoot:) position(date:) position(timeIntervalSinceEnd:) All the logs are retrieved. I cannot get only the subset requested by the timeframe I specified Sample A sample LogScreen that has 2 buttons is attached to the post 1 to fetch logs since the last time they have been fetched 1 to add a log The code has been simplified to ease the comprehension of the case, please be indulgent to the shortcuts that have been taken. LogScreen.swift References https://developer.apple.com/documentation/oslog/oslogstore https://developer.apple.com/forums/thread/705868 https://developer.apple.com/videos/play/wwdc2023/10226/ Environment XCode 15b7 iPhone 14 Pro / iOS 17
1
1
1.1k
Sep ’23
In Xcode 15 beta 6 console, structure log pause output when the number of log outputs over a certain amount.
When the number of log outputs over a certain amount, the structure log output is suspended. The os_log_debug code runs without error, but the Xcode console has no output. When use OS_ACTIVITY_DT_MODE=1 turnoff structure log, the output is normal. Does structure log in Xcode 15 beta 6 has bugs, or the structure log has upper limit in Xcode console output ?
3
0
839
Sep ’23
the printout on the Xcode console log is not showing in the "idevicesyslog" from libimobiledevice
I have an iOS application which is developed with C++, and my physical iPhone is connected to my Mac. While running the app via Xcode, I can easily view the printouts within the Xcode console. However, upon manually executing the app on the iPhone and utilizing the command "idevicesyslog -d -p myAppName" on my Mac the terminal, I notice that only specific logs generated by the .mm files are visible. And I'm unable to access the remaining traces, macros, and other details from the .h or .cpp files. Is there a method to ensure that all the logs I observe in the Xcode console are also displayed in "idevicesyslog"? Alternatively, are there any technique to show all the printout from .cpp and .h files.
3
0
2.5k
Aug ’23
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!
5
2
4.6k
Aug ’23
Logs are still private even after installing Wallet Logging Profile
Hi, I'm currently developing Apple Pay In-App Provisioning and have encountered an issue with viewing logs necessary for debugging. I've followed the instructions listed in https://download.developer.apple.com/iOS/iOS_Logs/Wallet_Logging_Instructions.pdf and have installed the relevant wallet profile. After repeating the issue, and opening up the sysdiagnose file on my mac, the logs that i'm interested in is still hidden with private tags. The device I'm using to develop on is an iPhone 11, runnning on iOS 16.5. The version of Xcode is 14.3. I am also using a sandbox account on the device if that is relevant to the issue. Below are screenshots of the logs I'm interested in. Any help in solving this issue will be greatly appreciated.
3
1
1.7k
Aug ’23
PreLoginAgents unable to log if built with XCode
Hi, I'm on MacBook Pro M2, macOS 13.3.1. I'm writing a feature that need to run before login. After some research I found PreLoginAgents sample code: https://developer.apple.com/library/archive/samplecode/PreLoginAgents/Introduction/Intro.html Followed README, installed pre-built agent and SSH to Macbook, then run: sudo syslog -c 0 -i syslog -w volia! SSH prints agent log, it is working. But if I build code with XCode, there is no log. I tried following changes with no luck: change LogManager acl log to os_log_info(OS_LOG_DEFAULT, "%s", [str UTF8String]), no log change to syslog(LOG_INFO, "%s", [str UTF8String]), has log! But change min deploy target from 10.9 to 11.0, syslog print no log What is the proper way to print PreLoginAgents log? Thanks!
2
0
806
Aug ’23
Any way to retrieve Debug and Info log messages remotely?
Note: I have read the Your Friend The System Log post, which was very helpful - thanks! I have a follow-up question. I have added support in our app for reading the log messages via OSLogStore. However, as you mention, the Debug and Info level messages do not show up when we read messages when not connected to a debugger. You mention two ways on iOS to change this configuration: Install a configuration profile created by Apple (all platforms). I assume all of these only work for the "com.apple.*" subsystems, correct? So this won't really work for 3rd-party apps like mine. Is this correct? Add an OSLogPreferences property to your app’s Info.plist (all platforms). Is there any official documentation for the OSLogPreferences Info.plist key? I was not able to find any. Does the value of "OSLogPreferences" follow the same dictionary structure described here? Thanks! Eric
2
0
968
Aug ’23
Default reduction of interpolated nonnumeric values doesn't work
I'm experimenting with the (relatively) new Logger API after watching WWDC20 session "Explore logging in Swift", and I don't see a default reduction of the values that was discussed in the talk. When I run this code, let i = A(a: "aaaa", b: 111) logger.error("Password: \(i)") // privacy: .auto logger.error("Password: \(i, privacy: .public)") logger.error("Password: \(i, privacy: .private)") logger.error("Password: \(i, privacy: .private(mask: .none))") logger.error("Password: \(i, privacy: .private(mask: .hash))") I get this output in both Xcode console and Console.app: 2023-08-20 22:55:57.373918+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.373988+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.374014+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.374032+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.374055+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 My assumption is that when running the code from Xcode with debug build configuration the system generously opens up any private values so I can inspect them conveniently. But when I ran my code with the release config, I got the same output. However, I want to test what data will be stored on my users' devices when I write different privacy options Any ideas why this happens?
1
0
539
Aug ’23
How to save a device's console log from Xcode
I'm assuming it's possible to stream the device log to a file, any clues? I'm trying to debug an app installation issue I am having with iOS 17, and hunting through the Console log is just super noisy. I want to just attach the log so I can hand it over to my developers on the team, but I don't seem to be seeing a way to save the Console log I am looking at in Xcode. Basically I'm looking for the equivalent of an adb shell logcat +pipe to storage that Is not that hard to do on an Android. By any means possible? I've not even tried using LLDB, will it let me do this, if so any clues where to start?
1
0
4.2k
Aug ’23
OSLog: anyway to get unified/combined logging from app and app extensions?
I've got a complex app extension and I'd like to be able to combine the logging from the app and the extension into a single file (for extraction/uploading etc.) I experimented adding the following code to both the app and the extension i.e. using the same subsystem for both app and extension logging. let subsystem = "mySubsystem" let logger = Logger(subsystem: subsystem, category: "main") logger.info("Log from within extension") // the version in the app says Log from within app do { let logStore = try OSLogStore(scope: .currentProcessIdentifier) let oneHourAgo = logStore.position(date: Date().addingTimeInterval(-3600)) let allEntries = try logStore.getEntries(at: oneHourAgo) let filtered = allEntries .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == subsystem } } The filtered content only contains logging from either the app or the extension. I suppose the issue might be the use of .currentProcessIdentifier as the scope, however that's the only scope that is defined. Is what is being attempted here possible? Is there any way to write to and extract a unified log for an app and app extension? If not, how about adding it, surely this would be something useful for people to be able to do
1
0
745
Aug ’23
Exporting logs with OSLogStore after app was killed
Hi, I'm currently working on exporting logs from a user's phone. Let's say I want to include an option in the settings that allows the user to retrieve all logs recorded via Logger. I've found that it's possible to use OSLogStore to get logs recorded via Logger. It has initializer with the scope of the current process identifier OSLogStore(scope: .currentProcessIdentifier). This method works fine until the app is killed or crashes. How can I retrieve the persistent logs in a manner similar to the log collect command? We need to access logs from when the app was killed or crashed, and we don't have direct access to the user's phone.
1
1
1.4k
Jul ’23
OSLog Request: split long output into structured and stdio instead of dropping long printouts entirely?
OSLog’s structured logging is nice, but the output length is limited compared with stdio’s. Currently, it looks like if I expect long variable-length print-outs, I’m forced to revert to using stdio. —or is this just an Xcode 15 beta 2 bug (discussed in the release notes) and fixed versions will match what stdio gives me? If not, could there be a way to configure oslog to fall-back to stdio dynamicallty based on whether the printout is too long or not? A custom fallback buffer allocator? Alternatively, what if I could still get the structured logging with the metadata, and use stdio for the rest of the message that doesn’t fit? That would be a nice way to guarantee that you get structured logging info without dropping the entire message.
3
0
1.4k
Jul ’23
structured logging is great, but logging fails with variables ?
I wanted to try structured logging with os_log in C++, but I found that it fails to print anything given a format string and a variable: eg. void example(std::string& str) { os_log_info(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_debug(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_error(OS_LOG_DEFAULT, "%s", str.c_str()); } This prints a blank row in the console, but with no text. How is this meant to work with variables? It only works with literals and constants now as far as I can tell. I'm looking forward to getting this working.
10
0
3.2k
Jun ’23
Recording Private Data in the System Log
I’ve discussed all of the following on DevForums before, but scattered across multiple threads. The issue of system log private data recently came up in another context and I decided to collect my thoughts in one place. If you have any questions or comments, start a new thread and tag it with OSLog so that I see it. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Recording Private Data in the System Log The unified system log on Apple platforms is a Thing of Wonder™. If you’re not convinced, go read Your Friend the System Log. One great feature of the system log is private data: If you tag a value as private, it’s omitted from the log by default. This keep personal information out the log, which is obviously a good thing. In some circumstances it makes sense to record private data. Imagine, for example, that you’re investigating a Gatekeeper problem on macOS and you see a log entry like this: type: info time: 2022-05-12 05:53:35.896830 -0700 process: XprotectService subsystem: com.apple.xprotect category: xprotect message: SecAssessment results: <private> (null) That looks interesting, but the assessment result, the thing that you really want to see, was omitted. Now look at the same log entry with the private data enabled: type: info time: 2022-05-12 05:55:21.673682 -0700 process: XprotectService subsystem: com.apple.xprotect category: xprotect message: SecAssessment results: { "assessment:authority" = { LSDownloadRiskCategoryKey = LSRiskCategoryMayContainUnsafeExecutable; "assessment:authority:flags" = 0; "assessment:authority:source" = "_XProtect"; }; "assessment:remote" = 1; "assessment:verdict" = 1; } (null) That’s much more helpful. There are two ways to enable recording of private data in the system log: Add an OSLogPreferences property in your app’s profile (all platforms). Create and install a custom configuration profile with the SystemLogging (com.apple.system.logging) payload (macOS only). WARNING Do not enable the recording of private data on a system you care about. Log entries are often tagged as private for a good reason. You don’t want them ending up in your system log! This is critically important when installing a configuration profile. Personally, I only do that on a ‘victim’ machine, one that doesn’t have any of my personal info and that I can erase when I’m done (typically a VM). Log Preferences Property Imagine an app with this code: let log = Logger(subsystem: "com.example.apple-samplecode.PrivateValueLogger", category: "app") let client: String = … log.debug("will answer the ultimate question, client: \(client)") let answer: Int = … lots of work … log.debug("did answer the ultimate question, answer: \(answer, privacy: .private)") Note This uses the Logger API in Swift but the same logic applies to all system log APIs. With this code both the client and answer values are considered private data, the first because that’s the default for strings and the second because it’s explicitly called out as private. And if you run the app outside of Xcode you’ll see that this private data is omitted: type: debug time: 16:55:23.994070+0100 process: PrivateValueLogger subsystem: com.example.apple-samplecode.PrivateValueLogger category: app message: will answer the ultimate question, client: <private> type: debug time: 16:55:23.994108+0100 process: PrivateValueLogger subsystem: com.example.apple-samplecode.PrivateValueLogger category: app message: did answer the ultimate question, answer: <private> Note When you use Xcode to run the app, it sets an environment variable, OS_ACTIVITY_DT_MODE, that changes the default handling of log entries. To record this private data, add the following to the app’s Info.plist file: <key>OSLogPreferences</key> <dict> <key>com.example.apple-samplecode.PrivateValueLogger</key> <dict> <key>app</key> <dict> <key>Enable-Private-Data</key> <true/> </dict> </dict> </dict> Now the private data is recorded in the log: … message: will answer the ultimate question, client: The Mice … message: did answer the ultimate question, answer: 42 This might not seem like a big deal — if you’re going to rebuild the app, you could just as easily change the code to log the values as public — but it has some important benefits: You only have to make this change in one place. If your app has lots of log points, this change affects them all. It works for code that you don’t control. If you need to record private data for library code running in your process, including system frameworks, you can do just that. It works on both macOS and iOS. Configuration Profile macOS has an extra trick up its sleeve, namely, the SystemLogging configuration profile payload (com.apple.system.logging). Use this to enable private data without modifying your code. For example, here’s an outline of a configuration profile that enables private data for the code shown earlier: … <dict> <key>PayloadContent</key> <array> <dict> … <key>PayloadType</key> <string>com.apple.system.logging</string> … <key>Subsystems</key> <dict> <key>com.example.apple-samplecode.PrivateValueLogger</key> <dict> <key>app</key> <dict> <key>Enable-Private-Data</key> <true/> </dict> </dict> </dict> </dict> </array> … </dict> </plist> Critically, this applies not just to your app but to all logging on the system. Continuing the Gatekeeper example from earlier, to see the assessment result, create a profile to enable private data for the com.apple.xprotect subsystem and the xprotect category. For detailed information on constructing a configuration profile, see Device Management. To get a head start with that, use Apple Configurator to create profile with a dummy payload and then use a text editor to modify that payload along the lines shown above. Revision History 2023-06-10 Added a warning about the risks of recording private data. 2022-05-12 First posted.
0
0
5.7k
Jun ’23
mdfind - Disable debug output: [UserQueryParser] Loading keywords and predicates for locale "de_CH"
Hey Whenever I run mdfind, it prints some annoying debug output. Example: $ mdfind …………… 2023-04-24 07:21:53.046 mdfind[642:1948002] [UserQueryParser] Loading keywords and predicates for locale "de_CH" 2023-04-24 07:21:53.047 mdfind[642:1948002] [UserQueryParser] Loading keywords and predicates for locale "de" … That's on macOS Ventura 13.3.1 (22E261). I've got another mac with an older macOS, and there mdfind didn't do this. While googling, I found a post on reddit with a "solution", which just filters out those lines from stderr, like so: function mdfind() { /usr/bin/mdfind $@ 2> >(grep --invert-match ' \[UserQueryParser\] ' >&2) } This does not solve the problem, it just hides it. Is there a way to turn off these debug messages? Thanks, Alexander
1
1
1.8k
Apr ’23
How do I persist os_signposts so they don't get lost when the in-memory buffer overflows?
I have a tool that generates thousands of signpost events a second. Unfortunately, when profiling earlier signposts appear to get lost over the course of the run because they are not persisted and the buffer for these runs out. How can I get these to persist? For reference, I've filed a feedback for this as FB12129526, and more context can be found (in meme form) here: https://federated.saagarjha.com/notice/AUm3AprLdVOnUPfiQy.
1
0
1.5k
Apr ’23
CarbonAPI DebugStr() deprecation
Howdy all, I'm in the process of eliminating some compiler warnings in a legacy project, and have come across a compiler warning for the usage of extern void DebugStr(ConstStr255Param debuggerMsg), defined in MacTypes.h as part of CarbonCore-769-1. I've looked through Apple's documentation for Cocoa and the MacOSX13.1 SDK but haven't found any leads on what I could/should replace it with. Can anyone point me in the right direction? Thanks!!
Replies
4
Boosts
0
Views
919
Activity
Sep ’23
Cannot get incremental logs from OSLogStore
Hello folks, I would like to incrementally retrieve logs of my iOS App from the Unified Logging System using OSLogStore. First I initialize the store store = try OSLogStore(scope: .currentProcessIdentifier) Second I set a position from which I want the logs using either : position = store.position(timeIntervalSinceLatestBoot: 0) // to get the logs from the launch of the App position = store.position(date: Date().addingTimeInterval(-10)) // to get the logs of the last 10 seconds Third I get the entries in the store from the position store.getEntries(at: position) Issue Whatever the position I set using from OSLogStore: position(timeIntervalSinceLatestBoot:) position(date:) position(timeIntervalSinceEnd:) All the logs are retrieved. I cannot get only the subset requested by the timeframe I specified Sample A sample LogScreen that has 2 buttons is attached to the post 1 to fetch logs since the last time they have been fetched 1 to add a log The code has been simplified to ease the comprehension of the case, please be indulgent to the shortcuts that have been taken. LogScreen.swift References https://developer.apple.com/documentation/oslog/oslogstore https://developer.apple.com/forums/thread/705868 https://developer.apple.com/videos/play/wwdc2023/10226/ Environment XCode 15b7 iPhone 14 Pro / iOS 17
Replies
1
Boosts
1
Views
1.1k
Activity
Sep ’23
In Xcode 15 beta 6 console, structure log pause output when the number of log outputs over a certain amount.
When the number of log outputs over a certain amount, the structure log output is suspended. The os_log_debug code runs without error, but the Xcode console has no output. When use OS_ACTIVITY_DT_MODE=1 turnoff structure log, the output is normal. Does structure log in Xcode 15 beta 6 has bugs, or the structure log has upper limit in Xcode console output ?
Replies
3
Boosts
0
Views
839
Activity
Sep ’23
Cannot get Xcode 15 structured logging to work
My problem is similar to this post but switching to an iOS 17 simulator does not fix the issue. As far as I know there should be no OS_ACTIVITY_DT_MODE set anywhere in my project but I'm not sure exactly where to check. I've tried in Beta 6 and 7 so far and I've set all of my minimums to iOS 17.
Replies
2
Boosts
0
Views
2.5k
Activity
Sep ’23
New debug console in Xcode 15 not active?
Hi! I am getting all debug output in text only format, without structure or color. I only noticed now after watching the respective WWDC session in Xcode 15 beta 8, but I am pretty sure this was the case in the previous betas as well. Is the new structured debug console activated by some setting I am overlooking?
Replies
1
Boosts
0
Views
2.6k
Activity
Sep ’23
the printout on the Xcode console log is not showing in the "idevicesyslog" from libimobiledevice
I have an iOS application which is developed with C++, and my physical iPhone is connected to my Mac. While running the app via Xcode, I can easily view the printouts within the Xcode console. However, upon manually executing the app on the iPhone and utilizing the command "idevicesyslog -d -p myAppName" on my Mac the terminal, I notice that only specific logs generated by the .mm files are visible. And I'm unable to access the remaining traces, macros, and other details from the .h or .cpp files. Is there a method to ensure that all the logs I observe in the Xcode console are also displayed in "idevicesyslog"? Alternatively, are there any technique to show all the printout from .cpp and .h files.
Replies
3
Boosts
0
Views
2.5k
Activity
Aug ’23
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!
Replies
5
Boosts
2
Views
4.6k
Activity
Aug ’23
Logs are still private even after installing Wallet Logging Profile
Hi, I'm currently developing Apple Pay In-App Provisioning and have encountered an issue with viewing logs necessary for debugging. I've followed the instructions listed in https://download.developer.apple.com/iOS/iOS_Logs/Wallet_Logging_Instructions.pdf and have installed the relevant wallet profile. After repeating the issue, and opening up the sysdiagnose file on my mac, the logs that i'm interested in is still hidden with private tags. The device I'm using to develop on is an iPhone 11, runnning on iOS 16.5. The version of Xcode is 14.3. I am also using a sandbox account on the device if that is relevant to the issue. Below are screenshots of the logs I'm interested in. Any help in solving this issue will be greatly appreciated.
Replies
3
Boosts
1
Views
1.7k
Activity
Aug ’23
PreLoginAgents unable to log if built with XCode
Hi, I'm on MacBook Pro M2, macOS 13.3.1. I'm writing a feature that need to run before login. After some research I found PreLoginAgents sample code: https://developer.apple.com/library/archive/samplecode/PreLoginAgents/Introduction/Intro.html Followed README, installed pre-built agent and SSH to Macbook, then run: sudo syslog -c 0 -i syslog -w volia! SSH prints agent log, it is working. But if I build code with XCode, there is no log. I tried following changes with no luck: change LogManager acl log to os_log_info(OS_LOG_DEFAULT, "%s", [str UTF8String]), no log change to syslog(LOG_INFO, "%s", [str UTF8String]), has log! But change min deploy target from 10.9 to 11.0, syslog print no log What is the proper way to print PreLoginAgents log? Thanks!
Replies
2
Boosts
0
Views
806
Activity
Aug ’23
Any way to retrieve Debug and Info log messages remotely?
Note: I have read the Your Friend The System Log post, which was very helpful - thanks! I have a follow-up question. I have added support in our app for reading the log messages via OSLogStore. However, as you mention, the Debug and Info level messages do not show up when we read messages when not connected to a debugger. You mention two ways on iOS to change this configuration: Install a configuration profile created by Apple (all platforms). I assume all of these only work for the "com.apple.*" subsystems, correct? So this won't really work for 3rd-party apps like mine. Is this correct? Add an OSLogPreferences property to your app’s Info.plist (all platforms). Is there any official documentation for the OSLogPreferences Info.plist key? I was not able to find any. Does the value of "OSLogPreferences" follow the same dictionary structure described here? Thanks! Eric
Replies
2
Boosts
0
Views
968
Activity
Aug ’23
Default reduction of interpolated nonnumeric values doesn't work
I'm experimenting with the (relatively) new Logger API after watching WWDC20 session "Explore logging in Swift", and I don't see a default reduction of the values that was discussed in the talk. When I run this code, let i = A(a: "aaaa", b: 111) logger.error("Password: \(i)") // privacy: .auto logger.error("Password: \(i, privacy: .public)") logger.error("Password: \(i, privacy: .private)") logger.error("Password: \(i, privacy: .private(mask: .none))") logger.error("Password: \(i, privacy: .private(mask: .hash))") I get this output in both Xcode console and Console.app: 2023-08-20 22:55:57.373918+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.373988+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.374014+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.374032+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 2023-08-20 22:55:57.374055+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111 My assumption is that when running the code from Xcode with debug build configuration the system generously opens up any private values so I can inspect them conveniently. But when I ran my code with the release config, I got the same output. However, I want to test what data will be stored on my users' devices when I write different privacy options Any ideas why this happens?
Replies
1
Boosts
0
Views
539
Activity
Aug ’23
It's urgent: Client side logs using OS 16 on iPhone
Hello Folks, I am simply trying to learn to take client-side logs using Xcode or any easy-to-use tools. Please help. That way I can figure out if the issue is on the client side or not. For the server side, I use Charles proxy and I know how to use that. Any help is appreciated!
Replies
1
Boosts
0
Views
712
Activity
Aug ’23
How to save a device's console log from Xcode
I'm assuming it's possible to stream the device log to a file, any clues? I'm trying to debug an app installation issue I am having with iOS 17, and hunting through the Console log is just super noisy. I want to just attach the log so I can hand it over to my developers on the team, but I don't seem to be seeing a way to save the Console log I am looking at in Xcode. Basically I'm looking for the equivalent of an adb shell logcat +pipe to storage that Is not that hard to do on an Android. By any means possible? I've not even tried using LLDB, will it let me do this, if so any clues where to start?
Replies
1
Boosts
0
Views
4.2k
Activity
Aug ’23
OSLog: anyway to get unified/combined logging from app and app extensions?
I've got a complex app extension and I'd like to be able to combine the logging from the app and the extension into a single file (for extraction/uploading etc.) I experimented adding the following code to both the app and the extension i.e. using the same subsystem for both app and extension logging. let subsystem = "mySubsystem" let logger = Logger(subsystem: subsystem, category: "main") logger.info("Log from within extension") // the version in the app says Log from within app do { let logStore = try OSLogStore(scope: .currentProcessIdentifier) let oneHourAgo = logStore.position(date: Date().addingTimeInterval(-3600)) let allEntries = try logStore.getEntries(at: oneHourAgo) let filtered = allEntries .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == subsystem } } The filtered content only contains logging from either the app or the extension. I suppose the issue might be the use of .currentProcessIdentifier as the scope, however that's the only scope that is defined. Is what is being attempted here possible? Is there any way to write to and extract a unified log for an app and app extension? If not, how about adding it, surely this would be something useful for people to be able to do
Replies
1
Boosts
0
Views
745
Activity
Aug ’23
Exporting logs with OSLogStore after app was killed
Hi, I'm currently working on exporting logs from a user's phone. Let's say I want to include an option in the settings that allows the user to retrieve all logs recorded via Logger. I've found that it's possible to use OSLogStore to get logs recorded via Logger. It has initializer with the scope of the current process identifier OSLogStore(scope: .currentProcessIdentifier). This method works fine until the app is killed or crashes. How can I retrieve the persistent logs in a manner similar to the log collect command? We need to access logs from when the app was killed or crashed, and we don't have direct access to the user's phone.
Replies
1
Boosts
1
Views
1.4k
Activity
Jul ’23
OSLog Request: split long output into structured and stdio instead of dropping long printouts entirely?
OSLog’s structured logging is nice, but the output length is limited compared with stdio’s. Currently, it looks like if I expect long variable-length print-outs, I’m forced to revert to using stdio. —or is this just an Xcode 15 beta 2 bug (discussed in the release notes) and fixed versions will match what stdio gives me? If not, could there be a way to configure oslog to fall-back to stdio dynamicallty based on whether the printout is too long or not? A custom fallback buffer allocator? Alternatively, what if I could still get the structured logging with the metadata, and use stdio for the rest of the message that doesn’t fit? That would be a nice way to guarantee that you get structured logging info without dropping the entire message.
Replies
3
Boosts
0
Views
1.4k
Activity
Jul ’23
structured logging is great, but logging fails with variables ?
I wanted to try structured logging with os_log in C++, but I found that it fails to print anything given a format string and a variable: eg. void example(std::string& str) { os_log_info(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_debug(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_error(OS_LOG_DEFAULT, "%s", str.c_str()); } This prints a blank row in the console, but with no text. How is this meant to work with variables? It only works with literals and constants now as far as I can tell. I'm looking forward to getting this working.
Replies
10
Boosts
0
Views
3.2k
Activity
Jun ’23
Recording Private Data in the System Log
I’ve discussed all of the following on DevForums before, but scattered across multiple threads. The issue of system log private data recently came up in another context and I decided to collect my thoughts in one place. If you have any questions or comments, start a new thread and tag it with OSLog so that I see it. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Recording Private Data in the System Log The unified system log on Apple platforms is a Thing of Wonder™. If you’re not convinced, go read Your Friend the System Log. One great feature of the system log is private data: If you tag a value as private, it’s omitted from the log by default. This keep personal information out the log, which is obviously a good thing. In some circumstances it makes sense to record private data. Imagine, for example, that you’re investigating a Gatekeeper problem on macOS and you see a log entry like this: type: info time: 2022-05-12 05:53:35.896830 -0700 process: XprotectService subsystem: com.apple.xprotect category: xprotect message: SecAssessment results: <private> (null) That looks interesting, but the assessment result, the thing that you really want to see, was omitted. Now look at the same log entry with the private data enabled: type: info time: 2022-05-12 05:55:21.673682 -0700 process: XprotectService subsystem: com.apple.xprotect category: xprotect message: SecAssessment results: { "assessment:authority" = { LSDownloadRiskCategoryKey = LSRiskCategoryMayContainUnsafeExecutable; "assessment:authority:flags" = 0; "assessment:authority:source" = "_XProtect"; }; "assessment:remote" = 1; "assessment:verdict" = 1; } (null) That’s much more helpful. There are two ways to enable recording of private data in the system log: Add an OSLogPreferences property in your app’s profile (all platforms). Create and install a custom configuration profile with the SystemLogging (com.apple.system.logging) payload (macOS only). WARNING Do not enable the recording of private data on a system you care about. Log entries are often tagged as private for a good reason. You don’t want them ending up in your system log! This is critically important when installing a configuration profile. Personally, I only do that on a ‘victim’ machine, one that doesn’t have any of my personal info and that I can erase when I’m done (typically a VM). Log Preferences Property Imagine an app with this code: let log = Logger(subsystem: "com.example.apple-samplecode.PrivateValueLogger", category: "app") let client: String = … log.debug("will answer the ultimate question, client: \(client)") let answer: Int = … lots of work … log.debug("did answer the ultimate question, answer: \(answer, privacy: .private)") Note This uses the Logger API in Swift but the same logic applies to all system log APIs. With this code both the client and answer values are considered private data, the first because that’s the default for strings and the second because it’s explicitly called out as private. And if you run the app outside of Xcode you’ll see that this private data is omitted: type: debug time: 16:55:23.994070+0100 process: PrivateValueLogger subsystem: com.example.apple-samplecode.PrivateValueLogger category: app message: will answer the ultimate question, client: <private> type: debug time: 16:55:23.994108+0100 process: PrivateValueLogger subsystem: com.example.apple-samplecode.PrivateValueLogger category: app message: did answer the ultimate question, answer: <private> Note When you use Xcode to run the app, it sets an environment variable, OS_ACTIVITY_DT_MODE, that changes the default handling of log entries. To record this private data, add the following to the app’s Info.plist file: <key>OSLogPreferences</key> <dict> <key>com.example.apple-samplecode.PrivateValueLogger</key> <dict> <key>app</key> <dict> <key>Enable-Private-Data</key> <true/> </dict> </dict> </dict> Now the private data is recorded in the log: … message: will answer the ultimate question, client: The Mice … message: did answer the ultimate question, answer: 42 This might not seem like a big deal — if you’re going to rebuild the app, you could just as easily change the code to log the values as public — but it has some important benefits: You only have to make this change in one place. If your app has lots of log points, this change affects them all. It works for code that you don’t control. If you need to record private data for library code running in your process, including system frameworks, you can do just that. It works on both macOS and iOS. Configuration Profile macOS has an extra trick up its sleeve, namely, the SystemLogging configuration profile payload (com.apple.system.logging). Use this to enable private data without modifying your code. For example, here’s an outline of a configuration profile that enables private data for the code shown earlier: … <dict> <key>PayloadContent</key> <array> <dict> … <key>PayloadType</key> <string>com.apple.system.logging</string> … <key>Subsystems</key> <dict> <key>com.example.apple-samplecode.PrivateValueLogger</key> <dict> <key>app</key> <dict> <key>Enable-Private-Data</key> <true/> </dict> </dict> </dict> </dict> </array> … </dict> </plist> Critically, this applies not just to your app but to all logging on the system. Continuing the Gatekeeper example from earlier, to see the assessment result, create a profile to enable private data for the com.apple.xprotect subsystem and the xprotect category. For detailed information on constructing a configuration profile, see Device Management. To get a head start with that, use Apple Configurator to create profile with a dummy payload and then use a text editor to modify that payload along the lines shown above. Revision History 2023-06-10 Added a warning about the risks of recording private data. 2022-05-12 First posted.
Replies
0
Boosts
0
Views
5.7k
Activity
Jun ’23
mdfind - Disable debug output: [UserQueryParser] Loading keywords and predicates for locale "de_CH"
Hey Whenever I run mdfind, it prints some annoying debug output. Example: $ mdfind …………… 2023-04-24 07:21:53.046 mdfind[642:1948002] [UserQueryParser] Loading keywords and predicates for locale "de_CH" 2023-04-24 07:21:53.047 mdfind[642:1948002] [UserQueryParser] Loading keywords and predicates for locale "de" … That's on macOS Ventura 13.3.1 (22E261). I've got another mac with an older macOS, and there mdfind didn't do this. While googling, I found a post on reddit with a "solution", which just filters out those lines from stderr, like so: function mdfind() { /usr/bin/mdfind $@ 2> >(grep --invert-match ' \[UserQueryParser\] ' >&2) } This does not solve the problem, it just hides it. Is there a way to turn off these debug messages? Thanks, Alexander
Replies
1
Boosts
1
Views
1.8k
Activity
Apr ’23
How do I persist os_signposts so they don't get lost when the in-memory buffer overflows?
I have a tool that generates thousands of signpost events a second. Unfortunately, when profiling earlier signposts appear to get lost over the course of the run because they are not persisted and the buffer for these runs out. How can I get these to persist? For reference, I've filed a feedback for this as FB12129526, and more context can be found (in meme form) here: https://federated.saagarjha.com/notice/AUm3AprLdVOnUPfiQy.
Replies
1
Boosts
0
Views
1.5k
Activity
Apr ’23