Well, according to the documentation, gl_Layer is actually for designating which face of a cubemap to use - which is different.
Somehow I confused gl_Layer with sampler2D/3D lod parameter, which allows a fragment shader to specify which texture mipmap to sample from.
Can I ask what it is you are trying to achieve through the use of gl_Layer ?
You are using glFrameBufferTexture, when there is a glFrameBufferTexture3D. EDIT: apparently the 3D variant is deprecated in favor of the function you are using, but it is still unclear to me what you are trying to accomplish.