Apple'S Unified Logging For Sysadmins: Macsysadmin 2017 Tim Sutton Sauce Labs
Apple'S Unified Logging For Sysadmins: Macsysadmin 2017 Tim Sutton Sauce Labs
Apple'S Unified Logging For Sysadmins: Macsysadmin 2017 Tim Sutton Sauce Labs
Sysadmins
MacSysAdmin 2017
Tim Sutton
Sauce Labs
http://www.deploystudio.com/Forums/viewtopic.php?
id=1952
MacSysAdmin 2010 (!)
syslog
• syslog -w
• -w waits for syslog information
• sudo syslog -c 0 -d
• log everything: Emergency to Debug
• syslog -c 0
• check filter mask
Penn State MacAdmins 2012
• Logging now to a database, no plaintext - only `log` and Console can read
these
• Default
• Info
• Debug
• "Special" types
• Error
• Fault
➜ ls /System/Library/Preferences/Logging/Resources
com.apple.WebDriver.plist
➜ ls /Library/Preferences/Logging/Subsystems
--style syslog
2017-09-30 02:46:10.603459-0400 localhost eoshostd[243]: (EmbeddedOSSupportHost) connect() failed, reason: <private>, giving up
--style json
{
"processImageUUID" : "469A00D6-3C4F-33EE-95F1-EDE17BCCB531",
"processUniqueID" : 243,
"threadID" : 2112,
"timestamp" : "2017-09-30 02:46:10.603459-0400",
"traceID" : 1260856231845957636,
"messageType" : "Error",
"senderProgramCounter" : 293550405,
"processID" : 243,
"machTimestamp" : 159540275634612,
"timezoneName" : "",
"eventMessage" : "connect() failed, reason: <private>, giving up",
"senderImageUUID" : "16538049-0951-3460-ABCD-8E6C06D631D6",
"processImagePath" : "\/usr\/libexec\/eoshostd",
"senderImagePath" : "\/System\/Library\/PrivateFrameworks\/EmbeddedOSSupportHost.framework\/Versions\/A\/EmbeddedOSSupportH
}
Metadata naming in Console.app, `log`
Console.app 'log' command
PID --process
`log` and predicates
• Quoting really matters for --predicate option!
• https://developer.apple.com/documentation/foundation/nspredicate
• https://github.com/munki/munki/wiki/Conditional-Items
Apple Developer Docs
`log config`
➜ sudo log config
System mode = INFO STREAM_LIVE
➜ /usr/libexec/PlistBuddy -c 'Print' \
/System/Library/Preferences/Logging/Subsystems/com.apple.notes.plist
Dict {
DEFAULT-OPTIONS = Dict {
Default-Privacy-Setting = Public
Enable-Oversize-Messages = true
Level = Dict {
Persist = Debug
Enable = Debug
}
TTL = Dict {
Error = 30
}
}
}
`log stats` (new in High Sierra)
stats Shows a breakdown of the events contained within a log datastore or archive. The following options can
be supplied to all modes of log stats:
--archive archive Display statistics for events stored in the given archive. The archive must be
a valid log archive bundle with the suffix .logarchive.
--sort events | bytes Sort tabulated data output by number of events, or number of bytes.
--count count | all Limit tabulated data to the given number of lines, or all displays all entries
in tables.
--style human | json Control the format style of the requested output mode.
--per-book Displays statistics per log book, the subsections of a log archive.
--predicate predicate Displays statistics for all events matching the given predicate.
`log stats` (new in High Sierra)
➜ log stats --predicate 'subsystem == "com.apple.notes"'
== predicate ===========================================================
size: 1,847 bytes (uncompressed)
start: Sat Sep 9 16:14:05 2017
end: Sat Sep 9 16:14:08 2017
processes:
[ events (%total), decomp. bytes (%total), image UUID, image ]
[ 20 ( 76.9%), 1,567 ( 84.8%), 65768508-7764-396D-9DC6-C3393641B613, com.apple.Notes.SpotlightIndexExt
[ 6 ( 23.1%), 280 ( 15.2%), A77F5314-1B8B-35B5-8376-62677A2DAC6F, com.apple.Notes.datastore ]
senders:
[ events (%total), decomp. bytes (%total), image UUID, image ]
[ 17 ( 65.4%), 1,519 ( 82.2%), D2373F71-3179-3516-9234-DCA97ABD4FD7, NotesShared ]
[ 6 ( 23.1%), 280 ( 15.2%), A77F5314-1B8B-35B5-8376-62677A2DAC6F, com.apple.Notes.datastore ]
[ 2 ( 7.7%), 32 ( 1.7%), 65768508-7764-396D-9DC6-C3393641B613, com.apple.Notes.SpotlightIndexExt
[ 1 ( 3.8%), 16 ( 0.9%), 4FB06CCB-58C3-3860-BC6C-455E0B36E1FD, Notes ]
categories:
[ events (%total), decomp. bytes (%total), category ]
[ 15 ( 57.7%), 1,251 ( 67.7%), Indexer ]
[ 8 ( 30.8%), 572 ( 31.0%), ]
eclecticlight.co/category/macs (Howard Oakley)
Consolation
Other uncertainties
"Offline" logs?
macops.ca/logging