My MacBook Air mid-2012 model running OS X Yosemite logs off automatically without any prior warning when I am working on it.
This has been happening since the latest update, to Yosemite.
The logs from the moment of logout are here:
To be more specific my Air has been connected to an external monitor both times and has been charging both times too!
Similar problems have been discussed on Apple Support Communities:
Best Answer
I have the same problem with a MacBook Pro Retina and since Yosemite.
I was able to track down the corresponding crash, at each occurance of the "log off" there is a WindowServer crash log generated. After goolging I've found this post in the Apple forums:
https://discussions.apple.com/message/26929324#26929324
Summary of the post (detailed instructions are in the post)
The bug could be due to a memory leak in the video memory. Users with external monitor are much more susceptible to have the bug. Because it crashes the WindowServer, all connected users are logged out, but sometimes some of their process still remain running.
I've done these steps, and I cannot be sure that it solve the problem. These random logout occured not every day, and sometimes multiple times in the same day. But since I applied them (this morning) they do not occur anylonger, but that's still a bit short to be sure.
Anyway worth a try!!