Okay, J., I know this is going to sound really simplistic, and possibly very annoying, but could you bell him? Yes, like a cat wears a bell. Since he's obviously very clever and well-developed in finding a way out, you need to know that he's getting out. If it were me, this is what I'd do:
Buy a couple sets of one-piece zip-up pajamas. Cut off the feet. Put them on him backward. Using a zip tie (which you can purchase in the hardware/automotive depts) attach a couple of jingle bells to the zipper. Or loosely zip-tie to his ankle. Zip ties require scissors to remove, and that's a lot more planning and skill than most two year old's can muster.
Told you it sounded nuts. But believe me, when I lost my son (outside, for thirty seconds, still heart-attack city!) this was the first thing I thought of doing! This way, you can still keep using a gate (which is safer than locking him in) and hear him when he starts his midnight wanderings.
Oh, and if your family celebrates Christmas, he'll be quite seasonal!
Best wishes!