Markets log gains