I'm creating logs using Apple's os.log
framework. I'm just making logs like:
os_log("Update: Lat: %{public}f | Long: %{private}f | RemainingTime: %{public}f ", log: log, type: .default, location.coordinate.latitude, location.coordinate.longitude, UIApplication.shared.backgroundTimeRemaining).
I do see the logs in console & debugger.
I've read this and I'm successfully able to download the container (just not sure if the container contains what I'm looking for or if this is the correct place to look at). Then I click on Show packages:
But after that I only see:
I looked into all files. The files just contained numbers like:
Should I be doing something extra or I'm looking in the wrong place?
EDIT1: After JAL's suggestion:
I looked into (Documents, Library, tmp). There are plist
and ktx
files. and function.data
& map.data
file.
I looked into these files:
and also these files:
I tried opening them with console but I get gibberish results like the image below:
EDIT2:
so first I didn't have permission to open /var/db/diagnostics
, I had to do sudo bash
. Then I did cd /var/db/diagnostics
and saw these files.
Events
FaultsAndErrors
Oversize
SpecialHandling
StateDumps
TTL
logdata.Persistent.20170724T212501.tracev3
logdata.Persistent.20170725T015616.tracev3
logdata.Persistent.20170725T134017.tracev3
logdata.Persistent.20170725T171020.tracev3
logdata.Persistent.20170725T213354.tracev3
logdata.Persistent.20170726T002702.tracev3
logdata.Persistent.20170726T144412.tracev3
logdata.Persistent.20170726T202128.tracev3
logdata.Persistent.20170727T021506.tracev3
logdata.Persistent.20170727T033929.tracev3
logdata.Persistent.20170727T075325.tracev3
logdata.Persistent.20170727T145233.tracev3
logdata.statistics.0.txt
logdata.statistics.1.txt
shutdown.log
Then I did open -a console logdata.Persistent.20170725T015616.tracev3
(I tried other .tracev3
files as well), but the console just opens and starts tracking realtime as if I just opened console normally...
You did not specify iOS, macOS, or tvOS in your question, so I am keeping my answer generic across all platforms.
Review WWDC 2016 - Session 721 - Unified Logging and Activity Tracing.
Logging data is stored in a new compressed binary format (
.tracev3
or.logarchive
files), that's what those "numbers" are. You must use Console.app or thelog
command line tool to open these files.You're looking in the wrong place for the log files. From the session video:
If you redirect stdout or stderr to a file (such as the code in this example), it should be in the Documents directory of your application's sandbox (or whatever directory you specified). Logs written to /var/db/diagnostics are generally unavailable to end users on iOS and tvOS.
After following the suggestions of this answer I was able to redirect the logs into the documents directory for my app's sandbox, then I was able to download my container/sandbox using this answer.
Once I clicked on show package contents I had this:
I opened the log files using console and the results I got were:
The Longitude should have showed up as
private
but since I had it ran through Xcode ie debug mode still the field was rendered public.You can also retrieve the logs remotely without any specific setup.
system_logs.logarchive
with Console.app