Post not yet marked as solved
I have a Swift 3 Cocoa application that uses Apple's Unified Logging, like this: - import os
class MyClass
{
@available(OSX 10.12, *)
static let scribe = OSLog(subsystem: "com.mycompany.myapp", category: "myapp")
func SomeFunction(){
if #available(OSX 10.12, *){
os_log("Test Error Message", log: MyClass.scribe, type: .error)
}
if #available(OSX 10.12, *){
os_log("Test Info Message", log: MyClass.scribe, type: .info)
}
if #available(OSX 10.12, *){
os_log("Test Debug Message", log: MyClass.scribe, type: .debug)
}
}
}Within the Console application, both Include Info Messages and Include Debug Messages are turned on.When os_log is called, only the error type message is visible in the Console application.Using Terminal, with the command, all message types are visible in the Terminal output: -sudo log stream --level debugI've tried running the Console app as root, via sudo from the command line and the same issue occurs; no debug or info messages can be seen, even though they're set to being turned on under the Action menu.Setting system-wide logging to be debug, has no effect on the Console application output:sudo log config --mode level:debugPlease can someone tell me what I'm missing and how can I view debug and info messages in the Console application?
Post not yet marked as solved
Hi, I am trying to collect OSLog's logs using the OSLog framework, but I am not being able to access them. I've seen some examples that use something like this:
swift
import OSLog
let myLogStore =try OSLogStore(scope: .currentProcessIdentifier)
but when I try to run it throws:
bash
main.swift:5:20: error: argument labels '(scope:)' do not match any available overloads
main.swift:5:20: note: overloads for 'OSLogStore' exist with these partially matching parameter lists: (URL: URL), (url: URL)
I couldn't find any solution on google so far...
I am running it on a Mac OS X's 10.15 with Darwin Kernel Version 19 and Swift version 5.2.2
Any guidance on how to collect logs by using this framework will be highly appreciated
Post not yet marked as solved
I'm looking to construct a custom logger API. For example:
log.verbose(Date(), "Begun process")
(That's contrived example, the point being some object and a message. I will then be manipulating both.)
Within my Log object I then want to transform the date value and the message into a final log message. "Nanoseconds: 9790324:: Begun process". If I was working with strings, it would be a pretty simple issue. But I'm not. It looks like Logger, which actually does the logging takes in a OSLogMessage which I cannot instantiate and cannot pass by value or reference. Even if I had just:
func verbose(_ date: Date, _ message: OSLogInterpolation) {
log(date: Date, level: .info, message: message)
}
func info(_ date: Date, _ message: OSLogInterpolation) {
log(date: Date, level: .default, message: message)
}
private func log(date: Date, level: OSLogType, message: OSLogInterpolation) {
// Neither of these work
log.log(level: level, message)
log.log(level: level, OSLogMessage(interpolation: message))
}
Ideally what I'd like is:
private func log(date: Date, level: OSLogType, message: OSLogInterpolation) {
let interpolation = "Nanoseconds: \(date.getNanoseconds):: " + message
log.log(level: level, OSLogMessage(interpolation: interpolation))
}
With the idea being that OSLogMessage is still respecting any privacy notices on the interpolation.
Post not yet marked as solved
How to Fix 'doesn't have get-task-allow' in LogEntry which was retrieved using OsLogStore.
Example log output :
2021-08-18 11:47:05 +0000 macOSTaskPolicy: (kav) may not get the taskport of (opendirectoryd) (pid: 131): (opendirectoryd) is hardened, (opendirectoryd) doesn't have get-task-allow, (kav) is not a declared debugger\
The above log is not having a proper log Message . Kindly help me to resolve this isse
Hi, all. I try logging some message of my console application.
Just like syslog daemon in linux, I want to change and apply facility and level printing if requested.
So, I just try to use syslog API and os_log API both of them.
And try to change syslog.conf, add asl.configuration in /etc/asl directory But, it seems not to be applied.
Only I can see, log messages can be gotten by using "log" command not saved to file.
How can i config just like syslog system in linux and apply this?
Thansk.
Post not yet marked as solved
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
Post not yet marked as solved
It seems like signposts generated with os_signpost() APIs are not appearing in the trace files collected with ktrace (ktrace artrace).
On the other hand, if the signposts are generated with kdebug_signpost APIs - they do show up correctly.
Is this expected behavior?
Specially since the kdebug_signpost APIs are now deprecated?
Thanks.
Devendra.
ps: The os_signpost generated signposts do appear if capturing with Instruments app, just that they are not captured by ktrace.
Post not yet marked as solved
Is it possible to get the URL access log when a client access websites via Open Proxy (I mean the proxy outside of the organization) as a system log?
Of course I think browser history records the access URL but it is not a log.
Than you in advance.
Post not yet marked as solved
I understand that in iOS 15 and macOS Monterey, I can easily access the log system to get log entries for my app like this:
let store = try OSLogStore(scope: .currentProcessIdentifier)
I can then query store for the log entries.
However, as it says right in the name, the store is only for current process, i.e current run of my app. When I try to get entries, I only get entries from the current run, even if I specify an earlier time like this:
guard let positionDate = Calendar.current.date(byAdding: .day, value: -7, to: Date()) else { return }
let position = store.position(date: positionDate)
let predicate = NSPredicate(format: "subsystem == 'com.exampl.emyAppSubsystem'")
let entries = try store.getEntries(with: [], at: position, matching: predicate)
for entry in entries {
print("Entry: \(entry.date) \(entry.composedMessage)")
}
Is there any way to access log entries for earlier runs of my app, e.g from days or weeks ago? Either on macOS or iOS?
Post not yet marked as solved
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
Post not yet marked as solved
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
Post not yet marked as solved
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.
Post not yet marked as solved
XCode version 13.2.1
I enabled os_log messages using the following code:
let myLog = OSLog(subsystem: "testing", category: "exploring")
override func viewDidLoad() {
os_log("LOGGING TEST BLAH BLAH", log: myLog)
print("Starting ViewDidLoad")
super.viewDidLoad()
os_log("LOGGING TEST BLAH BLAH", log: myLog)'
...
However, I do not see anything on the XCode console - just the print ("Starting ViewDidLoad").
Is there a setting in XCode to echo messages from the logger that needs to be turned on?
I understand that Logger is the preferred method now instead of os_log, but both should echo the log messages on XCode debug console from what I can tell..
Thanks!
Post not yet marked as solved
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
Post not yet marked as solved
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.
Post not yet marked as solved
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!
Post not yet marked as solved
Hi, I need to retrieve the app logs in a file to be sent via API only when needed.
I write the logs and recover them but only of the current instance!
If the app crashes or is closed, the old logs are deleted while I have to recover them at the next start.
I write log with Logger and recover them with OSLogStore.
here a sample snippet to write
func testLog(_ message: String){
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "myAppLog")
logger.error("Sample error msg")
}
and the snippet to load
func getLogEntries() throws -> [OSLogEntryLog] {
let logStore = try OSLogStore(scope: .currentProcessIdentifier)
let oneDayAgo = logStore.position(date: Date().addingTimeInterval(-3600*24))
let allEntries = try logStore.getEntries(at: oneDayAgo)
return allEntries
.compactMap { $0 as? OSLogEntryLog }
.filter { $0.subsystem == Logger.subsystem }
}
any clue?
Post not yet marked as solved
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
Post not yet marked as solved
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?
Post not yet marked as solved
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?