A big reason for the loyalty of the men to their generals was the general's leeway when it came to loot. For a good number of soldiers their pay, while equal across the empire, which depending on where they were stationed could make them relatively wealthy or relatively starving. A Legionnaire in Northern Britain would in the surrounding settlements be quite the VIP while a Legionnaire stationed in the Syria or Egypt was most times just another workman. These pay differences were equalised by the fact that after a battle the British Legionnaire would only have poor Picts to pillage while the Syrian would have his picks of relatively wealthy raiders and Persians.
In both cases, a good share of the loot would go the commanding officer(s) and, possibly, Rome itself. The share of such would be made at said commanders discretion. If he wanted to be seen as generous to his men - read: a leader to follow - said lion share would go to his men instead - read: he would bribe them. This kind of parcelling out loot was one thing that made Caeser so popular with his men - if they serve him with blood, they shall be rewarded with gold, a lot of gold. Of course, there were many other reasons for service towards your general but I can't help but think a unified loot code would go some way to bringing the legions loyalty from their generals to the state. Possibly something like 20-40-40 shared between Rome, the general and the men.