OSLog

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

OSLog Documentation

Posts under OSLog tag

27 results found
Post marked as unsolved
154 Views

Unsatisfied entitlements: com.apple.logging.local-store

In my sandboxed MacOS app I want to access OSLogStore programmatically to fetch logs for multi-component application (app, libraries, deriver) for further analysis. According to the documentation, - https://developer.apple.com/documentation/oslog/oslogstore/3366102-local the app should have com.apple.logging.local-storeentitlement. I have added this entitlement "by hand" to the entitlement file as I I can't find a correspondent entry in the Xcode -> Sign & Capabilities interface. When I run the app, I get Unsatisfied entitlements: com.apple.logging.local-store error and the app doesn't start. If I remove the entitlement, the app can't get access to the logd subsystem. How can I add com.apple.logging.local-store to my app? Should I request this not visible via Xcode configuration UI from apple? Thanks!
Asked
by kriki44.
Last updated .
Post marked as unsolved
183 Views

How to store or log output of OS Signpost flags

I am trying to store or log the output of signpost end flag so that i can do further work on them without viewing them on instruments. following are the things i have already tried. Tried to print the output of signpost emit functions such as below. PSLog(ossignpostintervalbegin(slogHandleAssetLoading, signpostId, "Editor: First Render Complete")) 2. tried to view it in logs under derived data folder but could not find it anywhere. I just want to either get the data logged by signpost to be stored in array or get printed on console so i can parse the logs of console and fetch it from there.
Asked
Last updated .
Post marked as unsolved
157 Views

Network Extension- Packet Filter vs Logs

Console.app shows a lot of logs from NEFilterPacketInterpose when you use a Network Extension (possibly a NEFilterPacketProvider) repeatedly. I'm a bit worried by these from a performance point of view considering that: there is a huge number of them over time. turning off developer mode via systemextensionsctl does not appear to disable those logs. these logs are printed for release flavors of NEs not just debug flavors. Questions: Is this pointless worrying and it does not have any impact on performances? Is there a way to turn them off (not just filter them in Console.app)?
Asked
Last updated .
Post marked as unsolved
135 Views

os_log does not show source information

We are using Universal logging facility for our product. Product is built via Xcode. The product's workspace consists of multiple projects (dynamic/static libs, executables, system extension, applications) The code is a mix of CPP/Objective C/Swift, when CPP is a major language. We expected oslog facility to output source information such as file name, module, function, source code line, but it does not happen neither in debug nor in release build. Is there anything we can do, beside adding the required constants explicitly to the oslog calls? We tried to run a simpler project with the same usage of os_log facility and got controversial results. There were full source info in the debug build: 2020-10-07 11:30:45.194143+0300 0x15abcf  Error    0x0         57515 0  <aaaa`f1() (main.cpp:23)> aaaa: [com.aa.bb:HHHHH] qqqfault: And partial source info in the release build: 2020-10-07 13:02:19.072344+0300 0x16c5ee  Error    0x0         58416 0  <aaaa`f1() (.cold.1)> aaaa: [com.aa.bb:HHHHH] qqqfault:
Asked
by AAFP.
Last updated .
Post marked as solved
150 Views

Remote Unified Logging after release?

I am looking for a logging solution that is usable after the app is released to help keep track of errors etc. Does the Apple "Unified Logging" allow you to do this? After a quick glance at the documentation it is not clear how I can view logs after release. If not is there any 'Apple way' of monitoring logs after release without having to use a third party solution like Firebase?
Asked
Last updated .
Post marked as unsolved
255 Views

'import OSLog' - could not build

'import OSLog' compiles well in all Xcode beta version including the 12.2, but makes an error "could not build Objective-C module 'OSLog'" in Xcode 12 release. Replacing with 'import os.log' works. I do not understand and cannot explain it. What is wrong?
Asked
by Pavel V.
Last updated .
Post marked as unsolved
135 Views

The problem of log not updating

In kext I use kprintf outputs log information for debugging. The running environment is product version: 10.14 buildversion: 18a391. After the system has been running for a period of time, I found that the log content is no longer updated by entering the command: log show -- predict 'process = = kernel " in the terminal. What's the reason? How to solve it! thank you!
Asked
Last updated .
Post marked as unsolved
164 Views

OSLog Tools for Examining Difficult Issues?

I've found Console.app much harder to use in recent years, and one of the issues is the firehose of data is much more difficult to examine when you don't know what you're looking for, especially if you have to turn on debug and info. As an example of a tool, I'm posting a script I wrote to gather likely subsystem/category names from other binaries. It's crude, but does a decent job when you're not sure where to start #!/usr/bin/swift import Foundation extension Process { &#9;&#9;class func launchedForLines(url: URL, args: [String], block: (String) -> Void) { &#9;&#9;&#9;&#9;let proc = Process(), pipe = Pipe(), eol = Data([0x0A]) &#9;&#9;&#9;&#9;proc.executableURL = url &#9;&#9;&#9;&#9;proc.arguments = args &#9;&#9;&#9;&#9;proc.standardOutput = pipe &#9;&#9;&#9;&#9;proc.launch() &#9;&#9;&#9;&#9;let output = pipe.fileHandleForReading &#9;&#9;&#9;&#9;var buffer = Data(capacity: Int(LINE_MAX)), chunk = output.availableData &#9;&#9;&#9;&#9;while !chunk.isEmpty { &#9;&#9;&#9;&#9;&#9;&#9;buffer.append(chunk) &#9;&#9;&#9;&#9;&#9;&#9;while let range = buffer.range(of: eol) { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let slice = buffer[0..<range.lowerBound] &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;buffer.replaceSubrange(0..<range.upperBound, with: Data()) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if let line = String(data: slice, encoding: .utf8) { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;block(line) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;chunk = output.availableData &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;proc.terminate() &#9;&#9;} } struct Log : Hashable, Equatable { &#9;&#9;let subsystem:String, category:String } func find_logs(url: URL) -> [Log]? { &#9;&#9;let literal = "literal pool for: \"", hold = "HOLD" &#9;&#9;var ring = [hold, hold], idx = false, logs = Set&lt;Log&gt;() &#9;&#9;Process.launchedForLines(url: URL(fileURLWithPath: "/usr/bin/otool", isDirectory: false), args: ["-tV", url.path], block: { (line) in &#9;&#9;&#9;&#9;if let range = line.range(of: literal) { &#9;&#9;&#9;&#9;&#9;&#9;let frag = line[range.upperBound..<line.index(before: line.endIndex)] &#9;&#9;&#9;&#9;&#9;&#9;ring[idx ? 1 : 0] = String(frag) &#9;&#9;&#9;&#9;&#9;&#9;idx = !idx &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else if line.range(of: "_os_log_create", options: .literal) != nil { &#9;&#9;&#9;&#9;&#9;&#9;let sub = ring[idx ? 1 : 0], cat = ring[idx ? 0 : 1] &#9;&#9;&#9;&#9;&#9;&#9;if sub != hold &amp;&amp; cat != hold &amp;&amp; sub.range(of: ".", options: .literal) != nil { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;logs.insert(Log(subsystem: sub, category: cat)) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;ring = [hold, hold] &#9;&#9;&#9;&#9;} &#9;&#9;}) &#9;&#9;return logs.isEmpty ? nil : Array(logs) } func check_mach(url: URL) -> Bool { &#9;&#9;guard let handle = try? FileHandle(forReadingFrom: url) else { &#9;&#9;&#9;&#9;return false &#9;&#9;} &#9;&#9;let size = MemoryLayout.size(ofValue: MH_MAGIC), magic = handle.readData(ofLength: size) &#9;&#9;try? handle.close() &#9;&#9;return magic.count == size &amp;&amp; [MH_MAGIC, MH_MAGIC_64, FAT_CIGAM, FAT_CIGAM_64].contains(magic.withUnsafeBytes({ $0.load(as: UInt32.self) })) } func enumerate(url: URL, block: (URL, URLFileResourceType) -> Void) { &#9;&#9;guard let type = try? url.resourceValues(forKeys: [.fileResourceTypeKey]).fileResourceType else { &#9;&#9;&#9;&#9;return &#9;&#9;} &#9;&#9;block(url, type) &#9;&#9;if (type == .directory) { &#9;&#9;&#9;&#9;_ = (try? FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: [.fileResourceTypeKey], options: []))?.map({ enumerate(url: $0, block: block) }) &#9;&#9;} } let args = ProcessInfo().arguments guard let base = args.count > 1 ? URL(fileURLWithPath: args[1]) : nil else { &#9;&#9;print("Specify exactly one argument, the path to search") &#9;&#9;exit(1) } enumerate(url: base) { (url, type) in &#9;&#9;autoreleasepool { &#9;&#9;&#9;&#9;if type == .regular &amp;&amp; check_mach(url: url), let logs = find_logs(url: url) { &#9;&#9;&#9;&#9;&#9;&#9;print("Found binary \(url.path)") &#9;&#9;&#9;&#9;&#9;&#9;_ = logs.map({ print("Subsystem: \($0.subsystem) Category: \($0.category)") }) &#9;&#9;&#9;&#9;} &#9;&#9;} }
Asked
by TyngJJ.
Last updated .
Post marked as unsolved
147 Views

Way of filtering the logging output

When my app contains a lot of logging I find the Xcode output console becomes overwhelmed with logging messages and it becomes easy to miss something important and/or difficult to focus on a particular area. Is there a way to filter by a particular category as well as by type?
Asked
by nickager.
Last updated .
Post marked as unsolved
268 Views

New logging in Swift, how do I remotely get these logs?

The new logging system looks nice, but the video didn't discuss how to get those logs from production devices. It only covered getting them during testing. If a customer contacts support from inside my app, I need to get a copy of the logs from that app/user. I currently am writing my logs to a text file, and then attaching that when they contact support. I realize that isn't ideal from a performance perspective. import os let logger = Logger(subsystem: "com.example.Fruta", category: "giftcards") logger.log("Started a task")
Asked
by AndrewM.
Last updated .
Post marked as solved
223 Views

Missing log method from current iOS 14 APIs

I noticed there is logging API in this session which doesn't seem to be public right now: logger.log("\(offerID, align: .left(columns: 10), privacy: .public)") OSLog has no log method (https://developer.apple.com/documentation/oslog) and log isn't part of the current SwiftLog API. (https://github.com/apple/swift-log) Is there another new API I missed or is this going to be coming in a future version?
Asked
by bjtitus.
Last updated .
Post marked as unsolved
132 Views

Help with find the Crash from this log..

Date/Time: 2020-06-21 09:58:48.8290 -0700 Launch Time: 2020-06-21 09:58:25.9986 -0700 OS Version: iPhone OS 13.5.1 (17F80) Release Type: User Baseband Version: n/a Report Version: 104 Exception Type: EXCCRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXCCORPSENOTIFY Triggered by Thread: 0 Last Exception Backtrace: (0x19eb3f794 0x19e861bcc 0x19ea35b98 0x1a2556c74 0x1a2143e94 0x1a21440b4 0x1a20e0cac 0x1a259ddd0 0x104f8b37c 0x104fffb60 0x104ff7070 0x1a2877c40 0x1a2143e94 0x1a20e0cac 0x1a287bbbc 0x1a2143e94 0x1a21440b4 0x1a20e0cac 0x1a2876cd8 0x1a2879858 0x1a2d4b84c 0x104fcda34 0x104f944d8 0x10519f030 0x1051a2f40 0x10517cad8 0x19e8049a8 0x19e805524 0x19e7b75b4 0x19eabd7fc 0x19eab86d0 0x19eab7ce8 0x1a8c0238c 0x1a2be6444 0x104f7012c 0x19e93f8f0) Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystemkernel.dylib 0x000000019e934d88 0x19e90f000 + 155016 1 libsystempthread.dylib 0x000000019e84d1e8 0x19e84b000 + 8680 2 libsystemc.dylib 0x000000019e7a0934 0x19e72e000 + 469300 3 libc++abi.dylib 0x000000019e908cc0 0x19e8f6000 + 76992 4 libc++abi.dylib 0x000000019e8fae10 0x19e8f6000 + 19984 5 libobjc.A.dylib 0x000000019e861e80 0x19e85c000 + 24192 6 libc++abi.dylib 0x000000019e90814c 0x19e8f6000 + 74060 7 libc++abi.dylib 0x000000019e9080e4 0x19e8f6000 + 73956 8 libdispatch.dylib 0x000000019e805538 0x19e7aa000 + 374072 9 libdispatch.dylib 0x000000019e7b75b4 0x19e7aa000 + 54708 10 CoreFoundation 0x000000019eabd7fc 0x19ea15000 + 690172 11 CoreFoundation 0x000000019eab86d0 0x19ea15000 + 669392 12 CoreFoundation 0x000000019eab7ce8 0x19ea15000 + 666856 13 GraphicsServices 0x00000001a8c0238c 0x1a8bff000 + 13196 14 UIKitCore 0x00000001a2be6444 0x1a21b8000 + 10675268 15 AppyHome 0x0000000104f7012c 0x104f64000 + 49452 16 libdyld.dylib 0x000000019e93f8f0 0x19e93e000 + 6384 Thread 1: 0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192 Thread 2: 0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192 Thread 3 name: com.apple.uikit.eventfetch-thread Thread 3: 0 libsystemkernel.dylib 0x000000019e913198 0x19e90f000 + 16792 1 libsystemkernel.dylib 0x000000019e91260c 0x19e90f000 + 13836 2 CoreFoundation 0x000000019eabd468 0x19ea15000 + 689256 3 CoreFoundation 0x000000019eab849c 0x19ea15000 + 668828 4 CoreFoundation 0x000000019eab7ce8 0x19ea15000 + 666856 5 Foundation 0x000000019edfb01c 0x19edf3000 + 32796 6 Foundation 0x000000019edfaefc 0x19edf3000 + 32508 7 UIKitCore 0x00000001a2c895dc 0x1a21b8000 + 11343324 8 Foundation 0x000000019ef29e20 0x19edf3000 + 1273376 9 libsystempthread.dylib 0x000000019e855d98 0x19e84b000 + 44440 10 libsystempthread.dylib 0x000000019e85974c 0x19e84b000 + 59212 Thread 4: 0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192 Thread 5: 0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192 Thread 6: 0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192 Thread 7: 0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192 Thread 8 name: com.apple.NSURLConnectionLoader Thread 8: 0 libsystemkernel.dylib 0x000000019e913198 0x19e90f000 + 16792 1 libsystemkernel.dylib 0x000000019e91260c 0x19e90f000 + 13836 2 CoreFoundation 0x000000019eabd468 0x19ea15000 + 689256 3 CoreFoundation 0x000000019eab849c 0x19ea15000 + 668828 4 CoreFoundation 0x000000019eab7ce8 0x19ea15000 + 666856 5 CFNetwork 0x00000001a1d78894 0x1a1d77000 + 6292 6 Foundation 0x000000019ef29e20 0x19edf3000 + 1273376 7 libsystempthread.dylib 0x000000019e855d98 0x19e84b000 + 44440 8 libsystempthread.dylib 0x000000019e85974c 0x19e84b000 + 59212 Thread 0 crashed with ARM Thread State (64-bit): x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000000000000 x4: 0x000000019e90bf29 x5: 0x000000016ae9a670 x6: 0x000000000000006e x7: 0xffffffffffffffec x8: 0x000000010541d840 x9: 0xe640c3b37bc4582a x10: 0x000000019e84d160 x11: 0x000000000000000b x12: 0x00000001d85a6080 x13: 0x0000000000000001 x14: 0x0000000000000010 x15: 0x0000000000000045 x16: 0x0000000000000148 x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x0000000000000006 x20: 0x0000000000000407 x21: 0x000000016ae9a670 x22: 0x000000010541d920 x23: 0x0000000000000000 x24: 0x0000000000000114 x25: 0x0000000283c60080 x26: 0x000000010541d920 x27: 0x00000000000020ff x28: 0x0000000002ffffff fp: 0x000000016ae9a5d0 lr: 0x000000019e84d1e8 sp: 0x000000016ae9a5b0 pc: 0x000000019e934d88 cpsr: 0x40000000 esr: 0x56000080 Address size fault Crash log - https://developer.apple.com/forums/content/attachment/17576994-cf79-4cd4-92f4-29a97a856be5
Asked
by Gangzter.
Last updated .