IMac – How the iMac turned off

imacmacosshutdown

I was working, then I received a phone call and left my iMac for a while. macOS Sierra is actually running.

I came back about 30 minutes later and found my Mac was turned off.

Since there are no phantoms at home, I thought I forgot I turned it off, maybe absentmindedly (I'm quite sure I didn't, anyway).

The question is: is there any way to check HOW the iMac turned off? (crash, eletricity grid issue, manual, etc.)

I read the console data but I don't know exactly what to search for (apparently there's no crash).

Update: The last thing I see in system.log:

Jan  4 10:33:53 M-iMac com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.pid.IDECacheDeleteAppExtension.2237): Path not allowed in target domain: type = pid, path = /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/XPCServices/RootDebuggingXPCService.xpc error = 147: The specified service did not ship in the requestor's bundle, origin = /Applications/Xcode.app/Contents/PlugIns/IDECacheDeleteAppExtension.appex    
Jan  4 10:33:54 M-iMac com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.pid.IDECacheDeleteAppExtension.2237): Path not allowed in target domain: type = pid, path = /Applications/Xcode.app/Contents/Frameworks/DFRSupportKit.framework/Versions/A/XPCServices/IDETouchBarSimulatorService.xpc error = 147: The specified service did not ship in the requestor's bundle, origin = /Applications/Xcode.app/Contents/PlugIns/IDECacheDeleteAppExtension.appex
Jan  4 10:33:54 M-iMac com.apple.xpc.launchd[1] (com.apple.nowplayingtouchui): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

Here I'm restarting (I suppose):

Jan  4 11:03:51 localhost bootlog[0]: BOOT_TIME 1483524231 0

Best Answer

There are other Questions on Ask Different regarding what the shutdown codes mean - e.g. Where to find shutdown causes errors list? [which links to a list maintained by one of the Ask Different senior members], but I went for the simplest, GUI-based way of finding the data, rather than using terminal.

[I need to know if this still work on Sierra, as comments suggest the data location may now be different]
This is from El Capitan.

Launch Console from Applications/Utilities
On the left, select 'All Messages' then top right in the search box, type 'shutdown'

enter image description here

Note that a Restart does not appear to generate any shutdown message.