How to send logs using Unified Logging?

I have done the following:


Still, I cannot figure out how to send a log file.


In this Apple Technical Note it states:


"In iOS 10+, use the Unified Logging APIs rather than NSLog, printf, and print."


But also:


"Provide a way for the user to send that log to you."


I am able to log using the os_log and related APIs. But how to send it anywhere? I know it would be in binary format (an .logarchive file?) and require it to be viewed by the new console.app.

Replies

One way to get

os_log
results from the user is via sysdiagnose. If the user takes a sysdiagnose, recent log entries will be captured therein. Once you unpack the resulting
sysdiagnose_***.tar.gz
file, you’ll find
system_logs.logarchive
file that you can explore with the
log
tool or the Console utility on macOS 10.12.

There are instructions on how to take a sysdiagnose on the Profiles and Logs page.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Is there a way to get all those os_log results without connecting the iPhone to a Mac?


Can we get the log info from user remotely? like user taps a button inside the app, and the console log info can be sent to a specific email address?



or for internal testing purpose

Can we print the log info into an UITextView inside one of our app pages so that the testers can see all the log info on the app directly without conncecting the iPhone to a Mac (we have many iPhones but not enough Macs in our company)?

Is there a way to get all those

os_log
results without connecting the iPhone to a Mac?

Not that I’m aware of (well, you can use a Windows machine but I don’t think that’s what you meant :-).

Can we get the log info from user remotely? like user taps a button inside the app, and the console log info can be sent to a specific email address?

No.

Can we print the log info into an UITextView …

I responded to this on your other thread.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hello,


Can you please explain me how to get logs generated by os_log function from a Windows Machine ?


Also, it's possible to redirect or apply a filter to my logs to be written to a .log file ?


Thanks

Can you please explain me how to get logs generated by

os_log
function from a Windows Machine ?

The system log is included in a sysdiagnose, and the standard instructions for sysdiagnose on our Bug Reporting > Profiles and Logs page explains how to get that on Windows.

Also, it's possible to redirect or apply a filter to my logs to be written to a

.log
file ?

There’s very little control over this on iOS. The general advice is that the app log the relevant stuff and let the OS sort out how to handle those log entries. You can then approach logging in one of two ways:

  • If you’re trying to debug a problem interactively, you can view the device’s system log via the Console app. Console has extensive filtering facilities.

  • If you’re trying to debug a problem being reported from the field, you need to have the user send you a sysdiagnose which you can filter using the Console app or the

    log
    tool.

Both options require the filtering be done on a Mac.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for your answer. It's works well on a device running iOS 10.

I can read all my logs in the file system_logs.logarchive extracted with itunes in the sysdiagnose archive.


Now, i'd like to know how it's possible to get my logs on a device running iOS 9 with this os_log API ?

I read somewhere that this API is backward compatible with asl functionalities. But in my sysdiagnose archive, there is no system_logs.logarchive file and nothing is printed to the Xcode console too.

So, where can I found my logs ? And it is really compatible with older ios versions ? If not, how it's possible to gather logs on thoses devices too ?


My devices are running iOS 9.3.5 and iOS 10.3.


Thanks!

Now, i'd like to know how it's possible to get my logs on a device running iOS 9 with this

os_log
API ?

Alas, that’s not going to happen.

I read somewhere that this API is backward compatible with asl functionalities.

Not in the way that you’re hoping for. The new logging system supports (most of) the ASL API. So, on iOS 10, if you have legacy ASL code it will most likely generate useful log entries that you can collect via sysdiagnose.

This will not help on iOS 9 though. If you want to support both iOS 9 and iOS 10, you’ll need some OS version specific code that either calls

os_log
or your own logging subsystem (you can’t want to use ASL on iOS 9 because the ASL implementation on iOS never persists it data to disk). And, as mentioned in the WWDC session, you’ll want to use a macro for this because otherwise you lose important location information.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"