Composing $L$ and $NL$
$M_2$, while running on $w$, calls $M_1(w)$ as a subroutine. So if $M_1(w)$'s output is stored on $M_2$'s working tape then it requires polynomial space, not logarithmic space. So, $M_2$ does not work in logarithmic space no matter it is deterministic or nondeterministic.   

Of course you could design your machine $M_2$ so that $M_1(w,i)$ would return $i$th bit on demand (on each call). In this case it would work in logarithmic space. But it depends on the problem you solve.