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
Related
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.
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.
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’m building Cocoa Touch Framework. I want to send my SDK logs to remote server. The approach I have applied is using below:
freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+”,stderr);
The above code writing console logs in file, but the problem is this also writing system logs and will write app logs which is not useful for me. I need only my SDK logs and using this I’m not able to filter logs while writing in file.
Second way is wherever i have NSLog in my code, write into file. But in this scenario I want to understand, how I will get exception messages if app crashes due to my SDK or will this continuous write and read operation makes app performance low.
So what is the best way to collect SDK logs and send it to server.
I wrote an iphone app that as a first function allows the user to download files. The user then manipulates these files in a particular way that wants them to be in memory.
It's not necessary that all of the files the user gets are in memory, just a few at a time that are well within memory constraints. However, the option to download the rest later is not available because of location assumptions (mainly that there is no assumption the user will be within wifi or data reception).
Is there a way around this? One example would be to have some sort of permanent write that I could access. Is that how the file storage apps solve this?
Thanks.
Could you use a server to do the manipulation instead of the app? iphone app sends the link to the server, server does the manipulation, and the the iphone downloads the manipulated link.