Born in Edinburgh on 17 February 1794, he was the second son of James Robertson, writer to the signet (died 15 April 1820) and Mary Saunders.
He was educated at Edinburgh high school, and was called to the Scottish bar on 27 May 1815, along with his friend John Wilson.
In 1848 he was elected by the students Lord Rector of Marischal College and University of Aberdeen, and received an honorary doctorate (LLD).
He was buried in the burial vault of Robert Pont in St Cuthbert's churchyard at the west end of Princes Street,[3] on the 15th of the same month.
[1] Lockhart made several rhyming epitaphs on Scott, and wrote a vivid description of his mock-heroic speech at the Burns dinner of 1818.