Resummation of nonglobal logarithms in QCD