I've read about the Unified Logging Framework as well as the new iOS 14 API regarding logging on devices, but I can't find anything that would enable me to write a log on a user's device to troubleshoot an issue, and for me to be able to review it? What is the current state of the art for doing this inside the Apple framework, or 3rd party library?
What you have read is how to write a log on the user's device. When you use os_log or the new Logger, and you log with anything but the lowest level, it is written into the log. The user can extract it using the log command in the Terminal. Of course you need to give instructions, so practice on your own device first.
For instance, if I hook my phone, TheMattPhone, to the computer, and say in the Terminal
sudo log collect --device-name "TheMattPhone" --last 1h
...then the result is that my home directory now contains a file called system_logs.logarchive. The user can zip that up and send it to you.
There are much more sophisticated commands that can extract just your app's logs, or even particular logs, depending on how you've configured the logger.
Note that the log written to the file will be redacted unless you mark interpolated material as public.
Related
Is there a way to retrieve logs after a crash with codename one? I have a process that does a large data conversion and my app crashes/closes while trying to complete it, only on iPhone.
I do have premium/crash protection on, but I don't get an email from this. I'm wondering if I can look at the logs and not have them wiped by closing/re-opening the app?
Opening the app appends to the logs, you can add a "Send Logs to developer" button or hidden feature and invoke Log.sendLogAsync() to email the log to you.
If this doesn't include what you need I would also suggest including the native logging cn1lib since it might include information about the crash.
Our iOS app has a subtle bug which is 100% reproducible on one of the team members’ device.
He is not a programmer, so he does not use XCode.
To investigate the bug, I plan to make a custom build with logging, ask him to launch it and reproduce the bug.
The question is where to write logs to and how to get them from his device with minimal friction.
I believe that logs must be written to some local file on iPhone, and then he send me this file say by email.
Are there any ideas how to make this sharing clear and easy for a non-programmer?
Little clarification:
In my concrete case I need to log a couple of (rather long) base64-encoded string.
The better way for your scenario is use slack, telegram or any chat application. Then instead log to the files, you can send log to a channel directly.
https://core.telegram.org/bots/api
https://api.slack.com/messaging/webhooks
In our applications, we write the log to the files, then server side supports the api to upload these files.
Looking at the changes introduced in 2016 to logging in iOS, I am wanting to locate the .logarchive file and attach it to an email programmatically in swift.
The following lead me to believe that this is not possible, but I was hoping someone out there has had some success.
Obtaining app logging
Release build debugging strategies
Unified Logging and Activity Tracing
These articles seem to suggest that the user needs to explicitly connect their device to a computer to access the logs. I am wanting to have the user simply tap a button in the app and be able to send us their console logs.
From iOS 15 OSLog can be read programmatically using OSLogStore. Unfortunately there is no system provided function to write it to a logarchive. For now you need to build the body with formatting of the file yourself.
I need to read the console logs from inside of the app, the idea is to use it in internal environment to help users report bugs to us with an internal library that comes bundled inside of the app.
How can I get the log in swift?
CLARIFICATION: I dont want to see the iOS logs from device in my computer, I need to get them programatically from inside of the app.
Maybe check out logging libraries like CocoaLumberjack[1]? It provides file logger (which you can configure to fit your needs: file limit, size limit, rolling, etc), then you can send such file to the server if needed.
[1] - https://github.com/CocoaLumberjack/CocoaLumberjack
I want to access the DJI-Go App Flight Plan log files similar to HealthyDrones App ( website for more about it ). This app verifies the DJI login credentials in their app But In DJI SDK Documentation there no information about integrating DJI-Login and accessing the log files.
Accessing the flight log files is not supported and undocumented. You can search the mobile device file system (depending on which DJI app you want to support) and find the file path for the log files but this can be changed by DJI at any time.
The format itself is also undocumented, meaning DJI can change or update the format at any time and break any apps that have reverse engineered the log files.
HD and a few others have decoded the files and you could contact then to see if they will share the information they found but as for finding a "supported" method to access the log files, it does not exist today.