The former Manchester City defender joined Aberdeen, initially on loan, from Brentford in January 2014.
"I was always confident we could try and get there and get a deal done," Aberdeen manager Derek McInnes told the club's website, "It is absolutely brilliant news."
BREAKING NEWS: Shay Logan signs new deal at Pittodrie! #StandFreehttps://t.co/7eNeklOqsR
— Aberdeen FC (@AberdeenFC) April 28, 2016